Skip to content

Instantly share code, notes, and snippets.

Created February 11, 2022 20:19
What would you like to do?
Use /proc/smaps to show the difference between resident and proportional set size memory
#!/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) {
waitpid $pid, 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment