Valgrind is a popular tool for detecting memory leaks. However, even if you tried to use Valgrind, before Python 3.5, you had to start over from compilation. However, since Python 3.6, you can change the memory allocator with the environment variable PYTHONMALLOC
. This makes it easier to investigate memory leaks.
PYTHONMALLOC=debug ./python membug.py
The mechanism of Valgrind is [monitor the behavior by replacing functions using LD_PRELOAD, which is an environment variable of dynamic linker](http://valgrind.org/docs/manual/mc-tech-docs.html#mc -tech-docs.overview). For this reason, it can be used to monitor functions in shared libraries.
Pydevenv
Valgrind
Linux Tools
Recommended Posts