in reply to Perl threads test on Windows: how to close thread handles?
Sorry, I spoke too soon. They are indeed thread handles (at least 1000 of them are). And there is a way of avoiding the leak. Detaching the threads rather than joining them prevents it.
#!/usr/bin/perl -w use strict; use threads; sub do_one_thread { warn "in kid\n"; return 1; } sub do_thread { my $t = threads->new(\&do_one_thread); $t->detach; } for my $i (1..1000) { warn "i=$i:---\n"; do_thread(); } warn "sleeping for 60 seconds (check handle count in Task Manager)\n"; <STDIN>;
Of course thats no good if you need the return values from the threads, and so it is still a bug.
|
|---|