in reply to Re: Test::More and semaphore handles on Windows
in thread Test::More and semaphore handles on Windows
No, $result does not get destroyed then because it has been inserted into @Test_Results (which is still in scope) -- perl's reference counting keeps track of this. Running the following program with a large number of iterations, you'll see the handle count go up and up, then it drops back to the original value at the end of the program (when @Test_Results has gone out of scope).
use strict; use threads; use threads::shared; sub test { my $niter = shift; my @Test_Results = (); share(@Test_Results); for (1 .. $niter) { my $result = {}; share($result); push(@Test_Results, $result); } } my $niter = shift or die "usage: $0 number-of-iterations\n"; test($niter); print "Look at handle count in Windows Task Manager\n"; print "Then press [RETURN] to exit...\n";<STDIN>;
|
|---|