Red Hat Bugzilla – Bug 1468410
System Python gc does not reclaim when large memory is allocated
Last modified: 2018-04-10 11:00:55 EDT
Created attachment 1295144 [details] screenshot of top and python Description of problem: gc of python that comes with RHEL7.3 does not collect all memory it allocates Version-Release number of selected component (if applicable): Red Hat Enterprise Linux Server release 7.3 (Maipo) Linux localhost.localdomain 3.10.0-514.26.2.el7.x86_64 #1 SMP Fri Jun 30 05:26:04 UTC 2017 x86_64 x86_ Python 2.7.5 (default, Aug 2 2016, 04:20:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2 How reproducible: d = [ {'sdfdfsdfsfef': 1} for x in xrange(10000000)] del d import gc; gc.collect() Steps to Reproduce: 1. Open python on RHEL7 and enter following python code 2. d = [ {'sdfdfsdfsfef': 1} for x in xrange(10000000)] 3. del d 4. import gc; gc.collect() 5. Run top or ps to get memory allocation of the process Actual results: The process still uses 2.4 GB of Memory Expected results: Mem usage less than 100KB Additional info:
I plan to look into this in the RHEL 7.5 devel phase.
Note that the memory is not leaked; it is only not "returned" to the OS; subsequent allocations will re-use the memory. That being said, this was fixed upstream (in Python 3.3 and 2.7.7) by using mmap() to allocate arenas and using pre-allocated pools for dicts. From an engineering POV, backporting the patch shouldn't be difficult.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2018:0833