Re: dealloc for cleanup versus freeing memory
Re: dealloc for cleanup versus freeing memory
- Subject: Re: dealloc for cleanup versus freeing memory
- From: Seth Pellegrino <email@hidden>
- Date: Sun, 5 Aug 2007 23:16:09 -0400
Kurt,
You might be interested in < http://developer.apple.com/documentation/
Cocoa/Conceptual/AppArchitecture/index.html#//apple_ref/doc/uid/
10000005i >.
Good luck!
Seth
On Aug 5, 2007, at 4:03 PM, Kurt Bigler wrote:
There has been discussion on this list in the past relating to
dealloc on
quit. For example in the thread "which cocoa objects to dealloc ?":
on 3/18/06 2:40 AM, j o a r <email@hidden> wrote:
Cocoa will skip over sending deallocation messages to objects when
your app is about to quit. This is an optimization,
My basic design problem is that coming from C++ experience I am
used to
using the equivalent of dealloc (the destructor) for all cleanup
purposes,
whether they pertain to releasing memory or not. In short it is
typical in
C++ that all types of of resource cleanup are taken care of via the
same
"method" that releases memory. Such resource cleanup may include
posting
files, communicating with other applications, and dealing with other
external resources that are not managed by the OS automatically.
So it may sound like a nice idea that Cocoa optimizes memory
release on
quit, but if this means dealloc is not called it means I have not
done all
the other non-memory related cleanup that I would typically do in
dealloc.
I'm not aware of any other generic place to put such cleanup actions,
besides dealloc, so please inform me if I'm missing something.
My specific problem is typical of the kinds of things I saw
reported in
several threads on this list: My custom view is not reliably
getting a
dealloc message on quit.
To make it more mysterious, the view gets a dealloc if the Command-Q
shortcut is used to quit, but not if Quit is selcted from the menu
using the
mouse. If anyone has any clues why this might be, I'd appreciate it.
I also notice that my window delegate never receives a dealloc,
even when
the window is closed explicitly, i.e. via the close button rather than
implicitly due to Quit. (In the close-button case, my custom view
*does*
receive a dealloc message.)
Thanks for any info.
-Kurt Bigler
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden