[issue33444] Memory leak/high usage on copy in different thread

Antoine Pitrou report at bugs.python.org
Tue May 8 13:45:33 EDT 2018


Antoine Pitrou <pitrou at free.fr> added the comment:

Yes, this looks surprising, but there is no memory leak here, just memory fragmentation in the glibc allocator.  This is the program I used to diagnose it:
https://gist.github.com/pitrou/6c5310d4c721436165666044e3c31158

At the end the program prints glibc allocator stats as returned by mallinfo() (see http://man7.org/linux/man-pages/man3/mallinfo.3.html). On my system, the process takes 480 MB RSS and "fordblks" (the total number of bytes in free blocks) is 478 MB. However, "keepcost" (the releasable free space) is only 30 MB.  The rest is probably interspersed with internal interpreter structures that have stayed alive.

The fragmentation seems to depend on the number of threads.  If you start the executor with only one thread, memory consumption is much lower.  This makes sense: by ensuring all operations happen in order with little concurrency, we minimize the chance that short-lived data gets interspersed with longer-lived data.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33444>
_______________________________________


More information about the Python-bugs-list mailing list