Re: NSApplication delegate not released on quit?
Re: NSApplication delegate not released on quit?
- Subject: Re: NSApplication delegate not released on quit?
- From: "Dennis C.De Mars" <email@hidden>
- Date: Sat, 14 Jun 2003 09:44:23 -0700
On Saturday, June 14, 2003, at 01:31 AM, Greg Hurrell wrote:
El sabado, 14 juni, 2003, a las 14:08 Australia/Adelaide, Sherm
Pendley escribis:
A programmer who makes the quite reasonable assumption that NSApp
will release at dealloc time the things it previously retained, will
be bitten by this bug.
I'm making no such assumption. What I'm relying on is the
well-documented and predictable behavior of any modern
protected-memory OS, Mac OS X included.
It's well documented that resources are returned to the OS. I don't
dispute that for a second.
But it is NOT well documented that certain AppKit methods break the
basic pattern of balancing each "retain" message with a "release".
There is no rule that you must balance every retain with a release. You
retain an object when you need it to stick around, and you release it
when you are finished with it. If you are never finished with it, you
never release it.
It is not documented that some AppKit classes break this "pattern"
because they never promise to follow it in the first place. I don' t
think it is stated anywhere in the documentation that all objects
created by AppKit methods will be released at some point, and any
application that assumes otherwise is likely to run into problems.
The only thing I expect from Appkit is that, when I release an object
belonging to an AppKit class, that it will release any temporary memory
it allocated. This is to prevent memory leaks.
As a matter of fact, I can think of an example where AppKit will not
release an object even when you tell it to. I beleive that constant
NSStrings that are created by using the @"string" construct are
effectively immortal. If you say:
NSString* str = @"A string";
...you can send "release" to str until you are blue in the face, and it
still won't go away. This doesn't bother me, though, because it cannot
cause a memory leak that would lead to memory usage growing
uncontrollably (the number of constant strings with this property is
fixed at compile time).
- Dennis D.
_______________________________________________
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.