Ok, here's a layman explanation:

Perl is free to do whatever it thinks might help your program run faster, usually at the expense of using more memory. You can't make any assumptions about memory usage of a script. In this case, perl probably created a compile-time constant for that which it copies when you ask for its value.

If you are working with extremely large data, you can't toss it around in the usual manners without large spikes of memory usage. You need to consider something like File::Map and then pass around references to that scalar instead of passing the scalar around by value. If you describe more of your needs, we can suggest better techniques to avoid loading it all into memory at once.


In reply to Re: Memory usage double expected by NERDVANA
in thread Memory usage double expected by sectokia

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.