Re: NSReleasePool issue
Re: NSReleasePool issue
- Subject: Re: NSReleasePool issue
- From: Kyle Sluder <email@hidden>
- Date: Sat, 21 Jun 2014 11:16:43 -0700
> On Jun 21, 2014, at 10:25 AM, Jens Alfke <email@hidden> wrote:
>
>
>> On Jun 21, 2014, at 7:39 AM, Kyle Sluder <email@hidden> wrote:
>>
>> You should add the @autoreleasepool around NSApplicationMain. I don't know why it's missing from the Mac template.
>
> I disagree. It’s pointless to have an autorelease pool that won’t be drained till the application quits.
The pool will never be drained, because NSApplicationMain never returns. There is no wasted work here.
> Anything autoreleased into that pool will be effectively leaked, and draining the pool on quit does nothing but slow down termination.
>
> The OP’s issue looks like an OS bug — there’s no application code on the stack at the time of the autorelease. Should be reported to Apple.
NSApplicationMain needs to interact with user defaults in order to parse the command line. It’s kind of unreasonable to expect Apple to eschew -autorelease in all code that can be called during startup. (I think the framework now even sets up an autorelease pool before calling +initialize methods. Not sure about +load.)
Perhaps NSApplicationMain should set up its own autorelease pool. But that’s apparently not how the framework is implemented today. And as far as I can remember, developers have _always_ been responsible for setting up a backstop autoreleasepool.
--Kyle Sluder
_______________________________________________
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