• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Garbage collection question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Garbage collection question


  • Subject: Re: Garbage collection question
  • From: Antonio Petri <email@hidden>
  • Date: Tue, 8 Dec 2009 17:53:15 +0000

The object referenced by aFoo should only be garbage collected after the variable goes out of scope. If the
editing context holds a strong reference to it, it shouldn't be garbage collected.

2009/12/8 Ricardo J. Parada <email@hidden>


Hi All,

If I have a local variable that is assigned a value and never read after that, is it possible that it may get garbage collected before the block where it was defined.  For example:

public void someMethod() {
Foo aFoo = new Foo(editingContext());
editingContext().saveChanges();
}

Will aFoo live until the end of someMethod()?  Or could it get garbage collected?

I'm asking because in the real app, Foo is a delegate of the editing context when it gets created and it finishes its job when the editing context saveChanges() is called.  But in a non-GUI app, we believe aFoo is getting garbage collected prematurely.  Those are someone else's findings but I though I should ask to see if that is right.

The documentation for NSNotificationCenter says the following:

Note: If the default NSNotificationCenter is the last object in your application with a reference to either an object registered to receive notifications or an object being observed, that object will be garbage collected.

P.S. Sorry if this is more a java question than a WebObjects question.  :-)

Thanks,
Ricardo




 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Garbage collection question
      • From: "Tom M. Blenko" <email@hidden>
References: 
 >Garbage collection question (From: "Ricardo J. Parada" <email@hidden>)

  • Prev by Date: Garbage collection question
  • Next by Date: Re: Garbage collection question
  • Previous by thread: Garbage collection question
  • Next by thread: Re: Garbage collection question
  • Index(es):
    • Date
    • Thread