Re: GCD dispatch workers and termination
Re: GCD dispatch workers and termination
- Subject: Re: GCD dispatch workers and termination
- From: Jason Harris <email@hidden>
- Date: Sun, 27 Mar 2011 23:11:27 +0200
On Mar 27, 2011, at 10:56 PM, Kyle Sluder wrote:
> On Sun, Mar 27, 2011 at 11:27 AM, Jason Harris <email@hidden> wrote:
>> Can anyone shed some light on why these DispatchWorkers are not terminating?
>
> Are they doing any work? If not, why does it matter? GCD might be
> keeping them around, anticipating more I/O-bound work. It is a thread
> pool API, after all.
Hmmm... It's possible... I noticed that when I don't actually use an NSTask and do some printf(stderr,...) or something like that then the DispatchWorkers do actually terminate.
Also if I change from:
[self performSelector:@selector(doWorkerLaunches) withObject:nil afterDelay:2.0];
to:
[self performSelector:@selector(doWorkerLaunches) withObject:nil afterDelay:2.0];
[self performSelector:@selector(doWorkerLaunches) withObject:nil afterDelay:10.0];
[self performSelector:@selector(doWorkerLaunches) withObject:nil afterDelay:20.0];
And look at this in instruments it looks like each time the doWorkerLaunches fires it starts a whole bunch of new workers and threads, ie it appears that none of these threads where the DispatchWorker was not terminated are being reused (I would think the DispatchWorker would have to terminate in order to reuse the thread right? But I am guessing here...)
(This sort of models the situation in my real application. Ie nothing... nothing... then a flood of say 15 dispatches, then nothing... nothing... nothing... another flood... etc.)
Thus it feels to me as if this is really leaking resources... since each thread has an overhead and looks like it is not being terminated and the number of threads is just growing...
Cheers,
Jas_______________________________________________
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