Note that there are some explanatory texts on larger screens.

plurals
  1. POUnderstanding Python fork and memory allocation errors
    primarykey
    data
    text
    <p>I have a memory intensive Python application (between hundreds of MB to several GB).<br> I have a couple of VERY SMALL Linux executables the main application needs to run, e.g.</p> <pre><code>child = Popen("make html", cwd = r'../../docs', stdout = PIPE, shell = True) child.wait() </code></pre> <p>When I run these external utilities (once, at the end of the long main process run) using <code>subprocess.Popen</code> I sometimes get <code>OSError: [Errno 12] Cannot allocate memory</code>.<br> I don't understand why... The requested process is tiny!<br> The system has enough memory for many more shells. </p> <p>I'm using Linux (Ubuntu 12.10, 64 bits), so I guess subprocess calls Fork.<br> And Fork forks my existing process, thus doubling the amount of memory consumed, and fails??<br> What happened to "copy on write"? </p> <p>Can I spawn a new process without fork (or at least without copying memory - starting fresh)?</p> <p>Related:</p> <p><a href="https://stackoverflow.com/questions/4856255/the-difference-between-fork-vfork-exec-and-clone">The difference between fork(), vfork(), exec() and clone()</a></p> <p><a href="https://stackoverflow.com/questions/12924048/fork-memory-allocation-behavior">fork () &amp; memory allocation behavior</a></p> <p><a href="https://stackoverflow.com/questions/1216794/python-subprocess-popen-erroring-with-oserror-errno-12-cannot-allocate-memory">Python subprocess.Popen erroring with OSError: [Errno 12] Cannot allocate memory after period of time</a></p> <p><a href="https://stackoverflow.com/questions/5306075/python-memory-allocation-error-using-subprocess-popen">Python memory allocation error using subprocess.Popen</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload