in reply to Re^2: ithreads memory leak
in thread ithreads memory leak
then kill the walking timer,
The fundamental problem with your code is this:
#! perl -slw use strict; use threads; sub sleeper { print "thread started; sleeping"; $SIG{'KILL'} = sub { print "Thread dieing"; threads->exit(); }; sleep( 1000 ); print "Thread dieing"; threads->detach; } my $t = threads->new( \&sleeper ); sleep 5; print "Killing thread"; $t->kill( 'KILL' )->detach; print "thread status: ", $t->error(); sleep 100 while 1;
Run that code and watch the process (top or whatever). It immediately creates a thread that just sleeps for a thousand seconds. The main thread then waits for 5 seconds and then (attempts to) kills the sleeping thread. But the thread never sees the "signal" ... until it finishes sleeping.
This is because those "signals" aren't real signals; but some home-brewed simulation of them that cannot even interrupt a sleep. They (the pseudo-signals), should never have been added to the threads api; and they should never be used!
And that explains the "memory growth" problem; you are expecting these threads to go away when before you start their replacements; but they simply won't.
And that's a problem for your architecture which is built around that premise.
I have 3 solutions for you: one is a quick fix; and the other two will required fairly extensive changes to your program.
(But its my dinner time right now, so I'll detail them in a while. I just wanted to warn you to ignore sundialsvc4 who has never posted a single line of working code here. Be warned!)
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: ithreads memory leak
by DNAb (Novice) on Apr 09, 2015 at 17:47 UTC | |
by BrowserUk (Patriarch) on Apr 09, 2015 at 19:00 UTC | |
by DNAb (Novice) on Apr 09, 2015 at 20:45 UTC | |
by BrowserUk (Patriarch) on Apr 09, 2015 at 21:20 UTC | |
by DNAb (Novice) on Apr 09, 2015 at 22:24 UTC |