On Mar 27, 2011, at 10:56 PM, Kyle Sluder wrote:
> On Sun, Mar 27, 2011 at 11:27 AM, Jason Harris <[email protected]> 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 protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]