|
Hi again,
I don't have specifics yet. But it seems memory usage is accumulating if I create & finish a bunch of threads. It's like finished and/or killed and/or exited threads never get freed. I've got to the tune of 5000 of them--most of them finished. The memory footprint grows and eventually it crashes--you know the drill. I reuse the same variable for my thread over and over again. e.g.
$my_th = threads->create(\&something);
$my_th->detach();
[it finishes]
[some semaphore or kill in place here to guarantee the first one is done]
$my_th = threads->create(\&something);
$my_th->detach();
[repeat]
I noticed when I don't detach it I get "finished and unjoined: 5000". I would have expected that if it's finished and detached, the handle would be freed. Maybe some basic information is retained so that threads-is_running() or is_detached() works, but I am reassigning the variable. As far as I'm concerned, it's gone.
I've tried this with threads-exit(), threads-kill('KILL'), threads-kill('KILL')-detach(), and just plain return, and that's the part I haven't isolated yet. Yes, I do a:
$SIG{'KILL'} = sub { threads->exit(); };
in my threads when I attempt a kill.
|