#! perl -slw use strict; use threads ( stack_size => 4096 ); use threads::shared; my @end :shared = (0) x 5000; sub thread { my $tid = threads->tid; Win32::Sleep( 10 ) until $end[ $tid ]; --$end[ $tid ]; return; } printf "Check memory: "; <>; threads->create ( \&thread )->detach for 1 .. 50; printf "Check memory: "; <>; for my $tid ( 1 .. 4950 ) { printf "\r$tid"; ++$end[ $tid ]; Win32::Sleep( 10 ) while $end[ $tid ]; threads->create ( \&thread )->detach; } ++$end[ $_ ] for 4950 .. 5000; printf "\nCheck memory: "; <>; __END__ c:\test>t-junk.pl Check memory: 6.6 MB Check memory: 123.4 MB 4950 Check memory: 137.1 MB