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 ]

acme (189)

acme
  (email not shown publicly)
http://www.astray.com/

Leon Brocard (aka acme) is an orange-loving Perl eurohacker with many varied contributions to the Perl community, including the GraphViz module on the CPAN. YAPC::Europe was all his fault. He is still looking for a Perl Monger group he can start which begins with the letter 'D'.

Journal of acme (189)

Thursday January 22, 2009
11:50 AM

Finite memory

[ #38328 ]

Computer memory is sadly still finite. Sometimes it's interesting to know how much memory a Perl script might be taking at a particular time. If you install the GTop development headers and library you can use:

#!perl
use strict;
use warnings;
use GTop ();
use Number::Bytes::Human qw(format_bytes);

my $gtop     = GTop->new;
my $proc_mem = $gtop->proc_mem($$);
my $size     = $proc_mem->size;
print format_bytes($size) . "\n";

Which produces something like:

6.2M

So you can find out that the module you were criticising isn't bloated code after all...

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.
  • To calculate the actual overhead you should substract what Perl needs for itself. See "perlbloat.pl" in the mod_perl manual [apache.org].

    That program has a small bug, if one wants to load a naked Foo.pm file, it gives Warning: Use of "require" without parentheses is ambiguous at (eval 4) line 1. To make it work correctly:

    -      if (eval "require $_") {
    +      if (eval "require q($_)") {