The funny thing is that above code does NOT use up any swap!

Your system will only use swap space if system wide memory utilization approaches or exceeds available physical memory. With per process virtual memory limited to 8192KB, each of your test processes can consume no more than this amount for the process itself and some additional amount for file buffers. You can see your total system memory and memory utilization with 'top' or 'vmstat'. Even if you have only 512MB on your system it will take more than 10 of your test processes to consume it all (10 processes would probably consume less than 100MB total).

As for your test processes running out of virtual memory: they are consuming about 100 bytes on each loop iteration (I don't know the exact amount but there is some overhead on the ~80 character string you are pushing onto your array in each iteration). It takes over 20,000 iterations to reach a total process memory utilization of 8192KB (22786 on my system) and, as others have pointed out, with a process being spawned and file I/O in each iteration, it takes considerable time to reach this number of iterations.

If you start your test and tail your output files, you should see them continue to grow until the processes fail. The child processes will continue after your main process has exited. Just be patient and eventually you should see an 'Out of memory!' for each child process.


In reply to Re: Swap hog - I do not understand this behavoir by ig
in thread Swap hog - I do not understand this behavoir by Plankton

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.