ruk·si

🐍 Python
Memory Profiling

Updated at 2019-01-26 21:13
pip install objgraph
brew install graphviz
brew install xdot
import objgraph

# shows what are the most common entities in memory
objgraph.show_most_common_types(limit=20);

# check what the last entity of a type looks like
objgraph.by_type('tuple')[-1]

# number of object types that don't have referents
objgraph.typestats(objgraph.get_leaking_objects())

# return object types that have increased the most since last call
objgraph.growth()

# checking what is referencing to the type
import random
obj = random.choice(objgraph.by_type('tuple'))
objgraph.show_backrefs([obj], max_depth=10)