foreach my $thr (threads->list) { # Don't join the main thread or ourselves if ($thr->tid && !threads::equal($thr, threads->self)) { $thr->join; } }
The main thread has an id of "0", and threads->list doesn't seem to return thread 0, so I wonder if that's a bug in the list() method, or if the conditional before the join is unnecessary.
Second, on this:
I thought it was a waste linking to that function on every call to it, so I tried to move it (and the other Win32::API function definition), to near the top of the program, but it ended up crashing perl. If I defined it near the top, and still defined it again on every call, it worked a couple of times, but then returned "The specified module could not be found" trying to link to it again after joining the threads.my $GetProcessMemoryInfo = Win32::API->new('psapi','GetProcessMemo +ryInfo', ['I', 'P', 'I'], 'I') or return $^E;
In reply to Re: Cleaning up threads so they do not leak memory. (Win32)
by runrig
in thread Cleaning up threads so they do not leak memory. (Win32)
by slloyd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |