Not logged in
Log in now
Create an account
Subscribe to LWN
Recent Features
Book review: Open Advice
Linux support for ARM big.LITTLE
LWN.net Weekly Edition for February 9, 2012
XBMC 11 "Eden"
LWN.net Weekly Edition for February 2, 2012
Errr, care to share it with us?
User-space software suspend
Posted Nov 4, 2005 0:43 UTC (Fri) by zblaxell (subscriber, #26385) [Link]
sub swapfree { open(PROC, "/proc/meminfo") or die "open: /proc/meminfo: $!"; my ($swapfree) = grep(/^SwapFree:/, <PROC>); close(PROC); $swapfree =~ s/\D+//gos; print STDERR "swapfree=$swapfree\n"; return $swapfree; }
my $last_swapfree = swapfree; my @blobs;
my $count = 0; my $total = 0;
my $start_time = time;
while ($last_swapfree <= (my $new_swapfree = swapfree)) { ++$count; push(@blobs, ('.' x (1048576 * $count))); $total += $count; print STDERR "${total}M allocated\n"; $last_swapfree = $new_swapfree; } system("ps m $$"); print STDERR time - $start_time, " seconds\n";
Copyright © 2012, Eklektix, Inc. Comments and public postings are copyrighted by their creators. Linux is a registered trademark of Linus Torvalds