Show quoted text> On the second and subsequent thread creations, $t holds a pointer to
> the remains of the previous thread; this gets cloned into the new
thread,
Show quoted text> and so the previous thread never gets freed. Rinse and repeat.
>
> So its not a bug, just a non-obvious consequence of the fact that a
new
Show quoted text> thread inherits a copy of everything in the old thread. If you undef
$t
Show quoted text> before each new thread creation, the problem goes away:
>
> ...
> undef $t;
> $t = threads->create( \&thread_sub );
>
>
>
use threads;
retry:
undef $t;
$t = threads->create( \&thread_sub );
$t->join;
undef $t;
goto retry;
sub thread_sub {
undef $t;
}
sorry, but it makes no different. it still eats up the memory.