Re: crash on custom NSWindow subclass dealloc
Re: crash on custom NSWindow subclass dealloc
- Subject: Re: crash on custom NSWindow subclass dealloc
- From: "Shawn Erickson" <email@hidden>
- Date: Wed, 19 Dec 2007 13:38:17 -0800
On Dec 19, 2007 1:19 AM, Wesley Smith <email@hidden> wrote:
> I have a custom subclass of NSWindow that I've defined a dealloc
> method for as so:
>
> - (void)dealloc
> {
> [ogl_view release];
> NSZoneFree([self zone], [self zone]);
> [super dealloc];
> }
NSZoneFree line is incorrect for a few reasons (one is your object
doesn't own the zone it was allocated from so it shouldn't attempt to
free that zone).
In dealloc you are responsible for releasing any objects your object
maintains a retain on and/or any memory your object allocated and
owns. You are not supposed free memory of your own object in dealloc.
Your object was sent a dealloc message by the runtime because the
runtime is about to destroy the object and the runtime wants you clean
up anything your object owns.
Even C++ you don't free the object itself in the destructor.
-Shawn
_______________________________________________
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