Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??


    I am facing an increasing memory usage over the time (during the application-run) and i am not sure what could be the root-cause.

When I have this problem, it usually is a global variable that continues to grow. In some cases, I use a subroutine that I call every so many seconds to show the memory status of the variables. Something like this (Note: I did this from memory so it may not compile asis).

sub ShowGrowth { use Devel::Size qw(total_size); our ( $BigScalar, %BigHash, @BigArray ); my $nokeys = keys ( %BigHash ); my $noitems = $#BigArray; print $DLOG "####### Devel::Size #########\n"; print $DLOG "\$BigScalar: ",total_size(\$BigScalar),"\n"; print $DLOG "\%BigHash: ",total_size(\%BigHash)," No of keys: $no +keys\n"; print $DLOG "\@BigArray: ",total_size(\@BigArray), " No of element +s: $noitems\n"; }
You may want to add the actual memory location to the log. I have learned the hard way that the variable that I think I'm clearing may be the wrong one. To get the memory address:
print $DLOG "\$BigScalar: ",total_size(\$BigScalar)," Addr: ",\$Bi +gScalar,"\n";
Leaking memory problems are never easy to find, but this code may give you some ideas on how to find the problem.


"Well done is better than well said." - Benjamin Franklin

In reply to Re: Memory usage of array and hashe variables by multiple inclusion. by flexvault
in thread Memory usage of array and hashe variables by multiple inclusion. by tobias_hofer

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (4)
    As of 2018-08-18 06:49 GMT
    Find Nodes?
      Voting Booth?
      Asked to put a square peg in a round hole, I would:

      Results (185 votes). Check out past polls.