C doesn't return freed virtual memory back to the operating system either. Unless you are running out of swap space, this shouldn't be of much concern, however.

Now, Perl certainly uses more memory than most things. But avoiding Perl because some number that "top" reports that you don't even understand very well might not be the best application of your time. (:

The two most common measure of memory use are roughly "virtual memory size" and "working set size". The first measures (roughly) how much swap space a process requires while it exists. The second measures (roughly) how much physical memory the process requires to actually get work done.

These days, if you are worried about running out of swap space, then I strongly suggest you configure more swap space for your system.

If you are worried about your system running slow (because it wants more physical memory), then you need to look at the working set size, and that size will go down when the process stops using the memory that it still has allocated to its virtual address space (whether the program was written in C or in Perl).

If you want a process to return memory to the operating system, then you pretty much have to restart the program. You can do that easily in Perl with: exec( $^X, $0, @ARGV );

        - tye (but my friends call me "Tye")

In reply to (tye)Re: memory usage woes by tye
in thread memory usage woes by urufu-san

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.