Re: Fw-Up: views removed from their superviews are automatically released?
Re: Fw-Up: views removed from their superviews are automatically released?
- Subject: Re: Fw-Up: views removed from their superviews are automatically released?
- From: Chris Thomas <email@hidden>
- Date: Wed, 20 Mar 2002 11:48:20 -0800
On 3/20/02 8:29 AM, "Andrea Perego" <email@hidden> wrote:
>
> The view is deallocated on the run loop because it has to mix with
>
> notifications and other things. To test that just place a NSLog() inside
>
> the view's dealloc method. It will be called later on. Of course, I
>
> didn't design that feature and I am just surmising why it is happening
>
> the way it does.
>
>
>
>
As a final remark, I'd wish to note that the delayed release
>
mechanism is smart enough to take into account the possibility that
>
the view might have been already deallocated in the meanwhile;
>
otherwise my app would have crashed during the tests I did. This is
>
just an example of decent behavior by a Cocoa class, but for me it's
>
also a reminder of the importance of defensive programming...;->
It actually isn't that smart -- you'd probably see difficult to reproduce
crashes in obscure circumstances if you were to rely on that behavior. Using
MallocDebug can help you discover/track down these sorts of problems.
Cocoa memory management, including the delayed release mechanism
(NSAutoreleasePool) is fully documented, by the way:
http://developer.apple.com/techpubs/macosx/Cocoa/TasksAndConcepts/Programmin
gTopics/MemoryMgmt/index.html
Chris
_______________________________________________
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.