Re: [SOLVED] Delayed -dealloc occurs on worker thread if object is "working".
Re: [SOLVED] Delayed -dealloc occurs on worker thread if object is "working".
- Subject: Re: [SOLVED] Delayed -dealloc occurs on worker thread if object is "working".
- From: Jerry Krinock <email@hidden>
- Date: Fri, 4 Jun 2010 08:27:26 -0700
On 2010 Jun 02, at 10:48, BJ Homer wrote:
> detachNewThreadSelector:target:withObject: retains both the target and the object.
Thank you, BJ. That explains everything.
On 2010 Jun 02, at 11:12, Jens Alfke wrote:
> It’s really not a good idea to obsess over the details of when objects get dealloced, unless of course you’re running into dealloced-object crashes or memory leaks.
Actually Jens, I was looking for a memory leak, but now I see that this was caused by a "thread leak". I had wrapped a kqueue in a target object which runs an infinite loop camping on kevent() in a secondary thread. Forever. The fix is, when done with the kqueue, I now close() its file descriptor, which I should do anyhow. Conveniently, this causes kevent() to return an error, running the loop one last time, because when I detect the error I break out of the loop. Then the thread ends and, as BJ says, releases the thread's target and object.
_______________________________________________
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