Re: Garbage collection question
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