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 protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to