Saturday 10:50 a.m.–11:20 a.m.
Track memory leaks in Python
Victor Stinner
- Audience level:
- Intermediate
- Category:
- Python Core (language, stdlib, etc.)
Description
Memory leaks in Python cannot be analyzed with traditional tools because Python uses reference counters. I will present tools specific to Python to help you to localize your memory leaks.
Abstract
* Global memory consumption of the process (RSS memory)
* Understand reference cycles
* Generate a picture representing links between objects
* Use `gc.get_objects()` and "manually" compute the size of objects
* [PEP 445][1]: "Add new APIs to customize Python memory allocators" implemented in Python 3.4
* Use the [pytracemalloc][3] module ([PEP 454][2]) to trace memory allocations at their creation
* Use [pyfailmalloc][4] module to inject MemoryError in your application to test how it behaves in low memory condition
[1]: http://www.python.org/dev/peps/pep-0445/
[2]: http://www.python.org/dev/peps/pep-0454/
[3]: http://pypi.python.org/pypi/pytracemalloc
[4]: http://pypi.python.org/pypi/pyfailmalloc