Tweaking Python Memory ManagementΒΆ


Linux glibc often hesitates to return memory to the OS. The mechanism is well explained in the issue tracker discussions. As such, CPython 3.3 changed to use mmap() to allocate arenas: and The enhancement was later back-ported to 2.7:

Alternatively, to resolve the wild glibc, one can use another memory allocator. Guys at ESN tried tcmalloc and found it is useful. For debugging memory issues tcmalloc looks like a good tool, as it offers quite nice heap analyzer.