memory_leak module
memory_leak provides useful methods for finding memory leaks in your Python code.
memory_leak makes to output the Python standard library tracemalloc in an easy-to-read format. It also comes with a summary using the popular library Pympler.
It will be useful in the early stages when you have no idea where the memory leak is. After that, attach the @profile() decorator to the methods likely to cause memory leaks using memory_profiler module, you can search the point at memory leak.
- param limit
(int) Limit output lines.
- param key_type
(str) Select ‘lineno’ or ‘traceback’ output. Defaults to ‘lineno’.
- param nframe
(int, optional) This can be specified only when key_type is ‘traceback’. Defaults to 5.
Example
>>> from memory_leak import Memory_leak
>>> m = Memory_leak(limit = 2, key_type = 'lineno')
>>> m.memory_leak_analyze_start()
>>>
>>> # ...Your application code
>>>
>>> m.memory_leak_analyze_stop()
- Reference:
- Document:
- GitHub:
- Zenn:
Special thanks to @nariaki3551(Nariaki Tateiwa) who created setup.py.