Use /proc/smaps to show the difference between resident and proportional set size memory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Linux::Smaps; | |
sub print_memusage { | |
my $smaps = Linux::Smaps->new; | |
printf "% 6s % 9d % 9d KB % 9d KB\n", $_[0], $$, $smaps->rss, $smaps->pss; | |
} | |
my @bigarray = (1..1_000_000); | |
print " LABEL PID RSS PSS\n"; | |
my $pid = fork; | |
die "failed to fork $!" unless defined $pid; | |
if ($pid == 0) { | |
print_memusage("CHILD"); | |
exit; | |
} | |
print_memusage("PARENT"); | |
waitpid $pid, 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment