Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of markjugg (792)

Saturday March 03, 2007
09:58 AM

Adam Kennedy's method for checking perl module memory usage

[ #32552 ]
I wanted to know: How much memory is my perl module consuming? Adam Kennedy had several times referenced the memory size of Perl modules, so I asked him how he figured it out. Here's the recipe he was kind enough to share, which I've reworked and embellished a bit for clarity:

Use ps.

> perl -de 1
> use Dependency::Of::YourMod::One;
> use Dependency::Of::YourMod::Two;

Then ps the process:

ps -O rss,vsz | grep 'perl -de'

The second and third numbers you'll see are the resident and virtual memory size.

> use YourMod;

Then ps the process again:

ps -O rss,vsz | grep 'perl -de'

That difference covers the needs of the module itself, and ignores the dependencies.

Now, that assumes that all your initialization runs at compile-time. If you have a singleton implementation you might need to create one to get the full module use.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I'll note that there's going to be some level of bloat from being in the debugger, but I've found it's generally close enough to be useful.