I agree on the fact that if the auto pool is introduced in main then its going 
to mask all the leaks in other parts of the code leading to unknown memory 
leaks. I see a divided option on this, but in OSX world this should be taken 
care by OS itself. Perhaps I will report this to Apple and see what they have 
to say. Does anyone know where to report the issue?

Regards,
Varun

From: Jens Alfke <j...@mooseyard.com<mailto:j...@mooseyard.com>>
Date: Sunday, 22 June 2014 5:24 am
To: Kyle Sluder <k...@ksluder.com<mailto:k...@ksluder.com>>
Cc: Development 
<varun.chandramo...@wontok.com<mailto:varun.chandramo...@wontok.com>>, 
Cocoa-Dev List <Cocoa-dev@lists.apple.com<mailto:Cocoa-dev@lists.apple.com>>
Subject: Re: NSReleasePool issue


On Jun 21, 2014, at 11:16 AM, Kyle Sluder 
<k...@ksluder.com<mailto:k...@ksluder.com>> wrote:

The pool will never be drained, because NSApplicationMain never returns. There 
is no wasted work here.

But it's still true that any object autoreleased into that pool is effectively 
leaked. It just won't be visible as such to the 'leaks' tool or Instruments, 
because technically that outer autorelease pool still has a reference to it. 
Nor will you be able to get that warning about an object being autoreleased 
without a pool, which is another way to catch such a leak. So it seems that all 
this does is hide potential leaks from you.

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.

Any code that runs at startup that uses autorelease should create its own 
temporary autorelease pool. There's apparently one such routine that doesn't: 
that's the actual bug here, and as I said, it should be reported to Apple.

-Jens

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to