Hi guys,

I'm using Perl Parallel::ForkManager module to speed up my program. I set the number of max processes to be 5. I'm pretty sure I write my code correctly because I've been using ForkManager a few times before. Everything else worked fine, except when one or more of the child processes need to make a system call to mv or touch files, it often fails with "cannot allocate memory" error. This seems quite random. When I rerun it, it could succeed (but could fail again too). The file it's trying to create or move is not big at all (<<100kb).

Did some research and seems like using "exec" could solve this because "system" creates a new child process while "exec" does not. However, in my case, I still have a lot of Perl code to run after the "system"/"exec" line, and "exec" will never return and run the rest Perl code if it succeeds. So "exec" does not work for me.

Anyone has any idea why I got this error and how I could fix it?

Thanks a lot!!!

Best,

Fei


In reply to "Cannot allocate memory" when making system calls using Perl Parallel::ForkManager by feiiiiiiiiiii

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.