[pypy-commit] pypy default: Just before spawning a subprocess, do a gc.collect(). This

arigo noreply at buildbot.pypy.org
Fri May 13 17:11:37 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r44134:138db333b3e4
Date: 2011-05-13 17:19 +0200
http://bitbucket.org/pypy/pypy/changeset/138db333b3e4/

Log:	Just before spawning a subprocess, do a gc.collect(). This should
	help if we are running on top of PyPy, if the subprocess is going to
	need a lot of RAM and we are using a lot too.

diff --git a/pypy/tool/runsubprocess.py b/pypy/tool/runsubprocess.py
--- a/pypy/tool/runsubprocess.py
+++ b/pypy/tool/runsubprocess.py
@@ -3,7 +3,7 @@
 if the current process already grew very large.
 """
 
-import sys
+import sys, gc
 import os
 from subprocess import PIPE, Popen
 
@@ -21,6 +21,11 @@
         else:
             args = [str(executable)] + args
         shell = False
+    # Just before spawning the subprocess, do a gc.collect().  This
+    # should help if we are running on top of PyPy, if the subprocess
+    # is going to need a lot of RAM and we are using a lot too.
+    gc.collect()
+    #
     pipe = Popen(args, stdout=PIPE, stderr=PIPE, shell=shell, env=env, cwd=cwd)
     stdout, stderr = pipe.communicate()
     return pipe.returncode, stdout, stderr


More information about the pypy-commit mailing list