Re: Puzzling run loop/autorelease pool question
Re: Puzzling run loop/autorelease pool question
- Subject: Re: Puzzling run loop/autorelease pool question
- From: Chris Suter <email@hidden>
- Date: Mon, 6 Apr 2009 09:51:12 +1000
Hi m,
On Mon, Apr 6, 2009 at 8:21 AM, m <email@hidden> wrote:
> I've uploaded a project that demonstrates the problem to
>
> <http://uielement.muratnkonar.com/UIElement.zip>
The problem is that you set-up your callback and your actual callback
is all via C; it's not an Objective-C interface so it makes no
guarantee that an autorelease pool will even exist, let alone whether
it will drain it. Bear in mind, that when your events are triggered no
other Objective-C code runs except for yours; it's all done in
CoreFoundation's runloop code.
Anyway, to solve it, all your callbacks should create their own
autorelease pool and release them before returning. Likewise, if you
care about exceptions, you should catch them in your callback
functions, although if all you're going to do is terminate anyway,
letting your program crash is as good a way as any.
Kind regards,
Chris
_______________________________________________
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