Re: NSApplication subclass crashes on 10.3 with Xcode 3
Re: NSApplication subclass crashes on 10.3 with Xcode 3
- Subject: Re: NSApplication subclass crashes on 10.3 with Xcode 3
- From: "Michael Ash" <email@hidden>
- Date: Wed, 17 Sep 2008 17:46:18 -0400
On Wed, Sep 17, 2008 at 12:13 PM, Jamie Hardt <email@hidden> wrote:
> Hello-
>
> I don't thin you can call dictionaryWithObject: without having an
> autorelease pool set up, and initialize might be getting called before
> autorelease pool for the main loop is getting setup. Try replacing
> dictionaryWithObject: with a standard alloc-init sequence.
You will never crash due to not having an autorelease pool around,
only log errors and leak. (An exception to this is, of course, if the
leaking causes you to run out of memory and crash.)
However, it should be noted that you must *always* have an autorelease
pool around any time you call into an Objective-C framework whose code
you do not fully control. Even doing an alloc/init with an
NSDictionary could, at least in theory, autorelease objects while
doing its work. If you call Cocoa from a context where it's not
certain that an autorelease pool has already been provided (such as
this), then you should always create your own.
But don't sweat it if you've forgotten it for an +initialize method.
Since they get run only once (or rather, at most only a few times if
you have subclasses) any potential leaks from this scenario won't be
very serious, and will be easy to track down if they ever start
happening.
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