• 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
Garbage collection question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Garbage collection question


  • Subject: Garbage collection question
  • From: "Ricardo J. Parada" <email@hidden>
  • Date: Tue, 08 Dec 2009 12:46:07 -0500



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

  • Follow-Ups:
    • Re: Garbage collection question
      • From: Antonio Petri <email@hidden>
  • Prev by Date: Snow Leopard and java 1.4 and 1.5
  • Next by Date: Re: Garbage collection question
  • Previous by thread: Snow Leopard and java 1.4 and 1.5
  • Next by thread: Re: Garbage collection question
  • Index(es):
    • Date
    • Thread