use strict; use warnings; use threads; use PDL; PDL::no_clone_skip_warning; sub mem { qx{ typeperf "\\Process(perl)\\Working Set" -sc 1 } =~ /(\d+)\.\d+\"$/m; ( my $s = $1 ) =~ s/(\d{1,3}?)(?=(\d{3})+$)/$1,/g; printf "%-30s: %12s\n", @_, $s } mem 'initially'; my $p = zeroes 50_000_000; mem 'we\'ve made a huge piddle!'; undef $p; mem 'and now it\'s gone'; sub test_arr { my @a = 1 .. ${ \10_000_000 }; mem 'we\'ve made a huge array!'; @a = undef; mem 'and now it\'s gone'; } async( \&test_arr )-> join; mem 'and now a thread is gone, too'; print "\nbut let\'s try it in main thread!\n\n"; test_arr; mem 'finally'; #### initially : 16,846,848 we've made a huge piddle! : 418,107,392 and now it's gone : 17,321,984 we've made a huge array! : 628,912,128 and now it's gone : 628,928,512 and now a thread is gone, too : 20,258,816 but let's try it in main thread! we've made a huge array! : 625,430,528 and now it's gone : 625,430,528 finally : 625,430,528