Re: Adding PDFPage to PDFDocument crashes
Re: Adding PDFPage to PDFDocument crashes
- Subject: Re: Adding PDFPage to PDFDocument crashes
- From: "Michael Ash" <email@hidden>
- Date: Tue, 2 Sep 2008 18:05:42 -0400
On Tue, Sep 2, 2008 at 3:28 PM, Andy Mroczkowski <email@hidden> wrote:
> The other two autoreleases are correct, though in general I suggest using
> regular release when you can. The overhead on autorelease isn't much but it
> is non-zero. Plus it makes over-release bugs a little harder to track down
> sometimes.
And if you do use autorelease, then put it right where you allocate
the object. For example:
NSTextView* view = [[[NSTextView alloc] initWithFrame:r] autorelease];
The advantage of this is that it places all of your memory management
right in the same place. It's much harder to forget to release
something if you use an autorelease right when you create the object
instead of using a release farther down. This also saves you from
accidentally leaking if you return from the middle of the function or
throw an exception.
However, as you say, this does have some extra overhead and can make
some bugs harder to find, so it's something of a tradeoff.
Mike
_______________________________________________
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