feiiiiiiiiiii has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: "Cannot allocate memory" when making system calls using Perl Parallel::ForkManager
by ww (Archbishop) on Mar 30, 2016 at 02:48 UTC |