• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: crash on custom NSWindow subclass dealloc
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >crash on custom NSWindow subclass dealloc (From: "Wesley Smith" <email@hidden>)

  • Prev by Date: Re: discovering if a process is busy
  • Next by Date: Re: discovering if a process is busy
  • Previous by thread: Re: crash on custom NSWindow subclass dealloc
  • Next by thread: Programatically Accessing Koteri's Functionality
  • Index(es):
    • Date
    • Thread