4 ms·
I discovered a similar trick few years ago: https://stackoverflow.com/questions/35660899/reduce-memory-fragmentation-with-malloc-mmap-threshold-and-malloc-mmap-
by lbolla 6y ago
I discovered a similar trick few years ago: https://stackoverflow.com/questions/35660899/reduce-memory-fragmentation-with-malloc-mmap-threshold-and-malloc-mmap-max https://stackoverflow.com/questions/35660899/reduce-memory-f...
The idea is to tweak when `mmap` or `malloc` are used by the Python interpreter. One allows memory to be released to the OS right away, whereas the other is not.
It is a useful trick if your application is generating lots of small objects.
- ublaze 6y agoThat's a neat trick and even simpler than what I wrote about.
- jnwatson 6y agoKeep in mind that’s from Python 2.5. Modern Python uses arenas that always use mmap.
- lbolla 6y agoI developed that tweak for Python 2.7 and I am running in production with Python 3.6. I tested with later Python versions, too. Do you have some pointers about arenas always using mmap? I'd like to know how that trick can work if that was the case.
- cmeacham98 6y agoIt doesn't work, that's their point. With modern python versions those env variables do next to nothing. It won't crash your python but it also won't help you.
- lbolla 6y agoMy point is that it does work. I tested with Python 2.7 and Python 3.6+.