Re: NSTask in separate thread is leaking memory
Re: NSTask in separate thread is leaking memory
- Subject: Re: NSTask in separate thread is leaking memory
- From: "Adam R. Maxwell" <email@hidden>
- Date: Wed, 04 Feb 2009 06:46:28 -0800
On Feb 4, 2009, at 3:25 PM, Oleg Krupnov wrote:
So the problem is solved for now, but one question still left open for
the future is the following: would it be thread-safe to use NSTask in
the way I originally attempted? If yes, why did it leak? The leak was
reported somewhere inside NSTask internal initialization code. Funny
enough, the leak disappeared if I made one superfluous -release call
on NSTask.
No, the NSTask class itself (at least up to 10.4) should only be used
from the main thread, particularly if you're spawning multiple tasks
at the same time from different threads. I suspect this is due to a
race condition in how it's notified of child exit, and it appears to
have changed in 10.5.
I wrote my own subclass to get around this, since a user finally had a
reproducible bug report. It's BSD licensed, if anyone's interested: http://bibdesk.svn.sourceforge.net/viewvc/bibdesk/trunk/bibdesk/BDSKTask.m?view=markup
--
Adam
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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