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: "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