Re: dealloc not called?
Re: dealloc not called?
- Subject: Re: dealloc not called?
- From: Raphael Sebbe <email@hidden>
- Date: Sat, 9 Feb 2002 10:55:11 +0100
I did not look at the sources, but it is possible that
SKTInspectorController is a singleton (there is only one global instance
for the entire application) that has roughly the same lifetime as the
application itself. So, there is no point to explicitely releasing it as
the app's VM space will eventually be destroyed.
All I can say is that it is good practice to still implement a dealloc
method that releases allocated resources, remove itself from the
notification center, etc. considering that the object can be reused in
another context...
Raphael
On Saturday, February 9, 2002, at 10:29 AM, Eric Wang wrote:
>
Hi,
>
>
I know this question has come up before but I wasn't able to find a
>
satisfactory answer. What I want to know is why an object's -dealloc
>
sometimes is not called. For example, in Apple's Sketch application,
>
SKTInspectorController's -dealloc method is never called. I tried
>
setting a
>
breakpoint and inserting an NSLog in the dealloc method, but no matter
>
what
>
I try -- closing the inspector window, closing the document window,
>
quitting
>
the application -- I don't see -dealloc executed. It appears to do
>
something
>
useful -- remove itself from the default notification center -- but why
>
is
>
it never called?
>
>
I searched the list and I did find a plausible response which stated
>
that
>
when an application quits, objects are not deallocated specifically,
>
they
>
just get cleaned up with all the memory belonging to a program. However,
>
this leads me to wonder, why implement -dealloc at all then? If it is
>
never
>
called, and program memory is automatically cleaned up when an
>
application
>
is quit anyway, what's the point in implementing -dealloc?
>
>
Hopefully, someone more experienced than I can shed some light on this
>
topic
>
for me. It has me thoroughly confused about memory management in Cocoa.
>
>
Eric Wang
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.