Linux::Smaps::Tiny - A minimal and fast alternative to Linux::Smaps


    use Linux::Smaps::Tiny qw(get_smaps_summary);

    my $summary = get_smaps_summary();
    my $size = $summary->{Size};
    my $shared_clean = $summary->{Shared_Clean};
    my $shared_dirty = $summary->{Shared_Dirty};

    print "Size / Clean / Dirty = $size / $shared_clean / $shared_dirty\n";


This module is a tiny interface to /proc/PID/smaps files. It was written because when we rolled out Linux::Smaps in some critical code at a Big Internet Company we experienced slowdowns that were solved by writing a more minimal version.

This module will try to use XS code to parse the smaps file, and if that doesn't work it'll fall back on a pure-Perl version.

If something like that isn't your use case you should probably use Linux::Smaps instead. Also note that Linux::Smaps itself has been optimized since this module was initially written.


The distribution comes with a contrib/ script. As of writing this is the speed of Linux::Smaps v.s. Linux::Smaps::Tiny, both the XS and PP versions:

                             Rate Linux::Smaps Linux::Smaps::Tiny::PP Linux::Smaps::Tiny
    Linux::Smaps            810/s           --                   -22%               -61%
    Linux::Smaps::Tiny::PP 1033/s          28%                     --               -51%
    Linux::Smaps::Tiny     2101/s         159%                   103%                 --



Takes an optional process id (defaults to self) returns a summary of the smaps data for the given process. Dies if the process does not exist.

Returns a hashref like this:

          'MMUPageSize' => '184',
          'Private_Clean' => '976',
          'Swap' => '0',
          'KernelPageSize' => '184',
          'Pss' => '1755',
          'Private_Dirty' => '772',
          'Referenced' => '2492',
          'Size' => '5456',
          'Shared_Clean' => '744',
          'Shared_Dirty' => '0',
          'Rss' => '2492'

Values are in kB.


Copyright 2011 Yves Orton <> and Ævar Arnfjörð Bjarmason <>

This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.