perl -wle 'system("ps uch $$");push @x, $i while ($i++ < 1_000_000);print "Elements in \@x: " . @x;; system("ps uch $$");' xxx 2365 0.0 0.0 3152 1248 pts/0 R+ 18:45 0:00 perl Elements in @x: 1000000 xxx 2365 20.0 0.5 22992 21056 pts/0 R+ 18:45 0:00 perl