[issue24085] large memory overhead when pyc is recompiled
Antoine Pitrou
report at bugs.python.org
Fri May 1 12:40:39 CEST 2015
Antoine Pitrou added the comment:
> Adding `import gc; gc.collect()` doesn't change the outcome afaict
Of course it doesn't. The memory has already been released.
"ru_maxrss" is the maximum memory consumption during the whole process lifetime. Add the following at the end of your script (Linux):
import os, re, resource
print(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)
with open("/proc/%d/status" % os.getpid(), "r") as f:
for line in f:
if line.split(':')[0] in ('VmHWM', 'VmRSS'):
print(line.strip())
And you'll see that VmRSS has already fallen back to the same level as when the pyc is not recompiled (it's a little bit more, perhaps due to fragmentation):
$ rm -r __pycache__/; ./python -c "import repro"
19244
VmHWM: 19244 kB
VmRSS: 12444 kB
$ ./python -c "import repro"
12152
VmHWM: 12152 kB
VmRSS: 12152 kB
("VmHWM" - the HighWater Mark - is the same as ru_maxrss)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24085>
_______________________________________
More information about the Python-bugs-list
mailing list