# New Ticket Created by Victor Efimov # Please include the string: [perl #119937] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=119937 > Below example (with $N high enough - 100 in my case) works fine if I terminate process group with Ctrl-C but start swapping if I wait for graceful process termination (i.e. with USR1, when exit() called). I think that's because Linux COW feature - after huge process forks, memory is not copied in real, until modified. And, it seems, that when Perl global destruction happens, all memory is modified in this particular example. So I am wondering, maybe it's possible to free simple data structures without modifying them. ============= #!/usr/bin/perl use strict; use warnings; my $N=20; my $x={}; $x->{a} = [map { $_ } 1..10_000_000 ]; $SIG{USR1} = sub { print "exiting $$\n"; exit(0); }; my @pids; for (1..$N) { if (my $pid = fork) { push @pids, $pid; } else { while() { sleep 1;} } } print "PRECC CTRL-C TO EXIT\n"; sleep 5; print "GRACEFUL EXIT\n"; kill 'USR1', $_ for @pids; ============= (tested with 5.10.1 and 5.19.4. Linux 2.6.38, 16GB ram)Thread Next