Saturday 10:50 a.m.–11:20 a.m.
Track memory leaks in Python
- Audience level:
- Python Core (language, stdlib, etc.)
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.
* 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]: "Add new APIs to customize Python memory allocators" implemented in Python 3.4 * Use the [pytracemalloc] module ([PEP 454]) to trace memory allocations at their creation * Use [pyfailmalloc] module to inject MemoryError in your application to test how it behaves in low memory condition : http://www.python.org/dev/peps/pep-0445/ : http://www.python.org/dev/peps/pep-0454/ : http://pypi.python.org/pypi/pytracemalloc : http://pypi.python.org/pypi/pyfailmalloc