Use Valgrind in Python

Introduction

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.

Reference material

Pydevenv

Valgrind

Python related

Linux Tools

Recommended Posts

Use Valgrind in Python
Use config.ini in Python
Use dates in Python
Use profiler in Python
Let's use def in python
Use Measurement Protocol in Python
Use callback function in Python
Use parameter store in Python
Use HTTP cache in Python
Use MongoDB ODM in Python
Use list-keyed dict in Python
Use Random Forest in Python
Use regular expressions in Python
Use Spyder in Python IDE
Use fabric as is in python (fabric3)
How to use SQLite in Python
Use rospy with virtualenv in Python3
How to use Mysql in python
Use Python in pyenv with NeoVim
How to use ChemSpider in Python
How to use PubChem in Python
Use OpenCV with Python 3 in Window
Python in optimization
CURL in python
Metaprogramming in Python
Python 3.3 in Anaconda
Geocoding in python
Meta-analysis in Python
Unittest in python
Epoch in Python
Discord in Python
Sudoku in Python
DCI in Python
quicksort in python
nCr in python
N-Gram in Python
Programming in python
Plink in Python
Constant in python
Lifegame in Python.
FizzBuzz in Python
Sqlite in python
StepAIC in Python
N-gram in python
LINE-Bot [0] in Python
Csv in python
Disassemble in Python
Reflection in Python
Constant in python
nCr in Python.
format in python
Scons in Python3
Puyo Puyo in python
python in virtualenv
PPAP in Python
Quad-tree in Python
Reflection in Python
Chemistry in Python
Hashable in python
DirectLiNGAM in Python
LiNGAM in Python