Re: which cocoa objects to dealloc ?
Re: which cocoa objects to dealloc ?
- Subject: Re: which cocoa objects to dealloc ?
- From: Karim Morsy <email@hidden>
- Date: Sat, 18 Mar 2006 12:04:09 +0100
Cocoa will skip over sending deallocation messages to objects when
your app is about to quit.
so it doesn't really make any sense to override dealloc in an app
controller and release any of the allocated memory, such as for
NSString, nsarray or custom obejcts etc.., right ?
This is an optimization, as all memory will be reclaimed by the OS
after the app has terminated in any case.
i see, so memory leaks can only occur during runtime and never after
an app has terminated, be it normally or due to a chrash ?
thanks for the advise,
Karim
On Mar 18, 2006, at 11:40 AM, j o a r wrote:
On 18 mar 2006, at 11.25, Karim Morsy wrote:
put logs in all of my custom object''s dealloc methods and
obviously none of them seems to get called when the app terminates.
This is a really frequently asked question, so it's probably not
documented well enough...
Cocoa will skip over sending deallocation messages to objects when
your app is about to quit. This is an optimization, as all memory
will be reclaimed by the OS after the app has terminated in any case.
Check the NSApplication termination notification if there's some
work that you need to perform at this time. Don't overload your
memory management primitive methods for this purpose.
for example, my custom NSView... when I send release to it before
the app quites nothing happens. if I send release twice the app
crashes. so in short...do I have to explicitly send dealloc to ANY
custom object I create, be it a view, a controller, or something
else ?
Never, ever, send dealloc to anything! Follow the Cocoa memory
management guidelines, and let Cocoa deal with the rest.
j o a r
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden