Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/denis-ryzhkov/mem_top

Shows top suspects for memory leaks in your Python program.
https://github.com/denis-ryzhkov/mem_top

Last synced: 3 months ago
JSON representation

Shows top suspects for memory leaks in your Python program.

Awesome Lists containing this project

README

        

# mem_top

Shows top suspects for memory leaks in your Python program.

## Usage

pip install mem_top
from mem_top import mem_top

# From time to time:
logging.debug(mem_top())
# print(mem_top())

# Notice which counters keep increasing over time - they are the suspects.

## Counters

`mem_top` iterates all objects found in memory and calculates:

* refs - number of direct references from this object to other objects, like keys and values of dict
* E.g. a dict `{("some", "complex", "key"): "value"}` will have `refs: 2` - 1 ref for key, 1 ref for value
* Its key `("some", "complex", "key")` will have `refs: 3` - 1 ref per item
* bytes - size of this object in bytes
* types - number of objects of this type still kept in memory after garbage collection

## Real life example

refs:
144997 defaultdict(, { {'.:..............:.......': {...
1578 {...
968 {...
968 {...
968 {...
767 [...
726 {...
608 {...

types:
292499
217912
72702
72702
12340
MIT License