Hi!

I have a very simple perl hello-world script.
I use GTop utility to measure the memory taken by the script.
The results GTop provides confuse me.

When I run the script from the command line GTop says it consumes 7M.
However when I run the script under mod_perl it consumes 54M.
So much?!

Why script memory grows so much under mod_perl?
Or maybe I measure the memory in a wrong way?
How do you profile perl script memory?

Here are the script and its output (I have added commas manually to easily read the numbers)

1. Run from command-line perl simple.pl size: 7,282688 share: 2,027520 diff: 5,255168 2. Run under mod_perl size: 54,878208 share: 4,661248 diff: 50,216960 Script simple.pl #!/usr/bin/perl use strict; use warnings; use CGI (); my $cgi = CGI->new; print $cgi->header('text/plain'); use GTop; print "Hello, world!\n"; my $m = GTop->new->proc_mem($$); print "size: ".$m->size."\n"; print "share: ".$m->share."\n"; my $diff = $m->size - $m->share; print "diff: $diff\n";

In reply to Can I compute memory taken by a perl script? by donald128

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.