objgraph
Object graph visualization and memory leak detection for Python — shows what objects are in memory and what references them. objgraph features: show_most_common_types() for top object counts by type, show_growth() for new objects since last check, find_backref_chain() for reference chains, show_backrefs()/show_refs() for object reference graphs (requires graphviz), get_leaking_objects() for objects with no referrers, count() for type count, at_addrs() for objects at specific memory addresses, and typestats()/get_new_ids() for tracking object creation. Essential for finding Python memory leaks.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Memory analysis tool that can inspect all Python objects in memory including those containing secrets. show_backrefs() output may include object reprs with sensitive data. Never run objgraph on production systems handling credentials — output may contain plaintext secrets. Development and debugging use only.
⚡ Reliability
Best When
Diagnosing Python memory leaks during development — objgraph's show_growth() and show_backrefs() quickly identify what objects are leaking and what's keeping them alive.
Avoid When
Production monitoring (use psutil), memory size analysis (use pympler), or automated garbage collection management (use gc module).
Use Cases
- • Agent memory leak detection — import objgraph; objgraph.show_growth(limit=10) — show top 10 types with most growth; agent runs this before and after processing to find leaks; output: list type: 1234 (+567); repeated calls show only new growth since last call
- • Agent object count snapshot — import gc; gc.collect(); most_common = objgraph.most_common_types(limit=20) — garbage collect then count; agent health check shows which types dominate memory; compare across time to identify growing types
- • Agent reference chain — import io; buf = io.StringIO(); objgraph.show_backrefs(leaking_object, output=buf); print(buf.getvalue()) — text representation of what references object; agent finds why object isn't being garbage collected; show_backrefs() reveals unexpected references keeping objects alive
- • Agent leak finding — leaking = objgraph.get_leaking_objects(); print(f'{len(leaking)} objects with no referrers'); objgraph.show_most_common_types(objects=leaking) — objects with no referrers; agent identifies garbage-eligible objects stuck in cycles; combine with gc.collect() to distinguish cycles from leaks
- • Agent periodic monitoring — import objgraph; baseline = objgraph.typestats(); process_batch(); current = objgraph.typestats(); new_types = {t: current.get(t,0) - baseline.get(t,0) for t in current if current.get(t,0) > baseline.get(t,0)}; print(sorted(new_types.items(), key=lambda x: -x[1])[:10]) — manual growth tracking; agent monitors object growth per batch
Not For
- • Production monitoring — objgraph is development/debugging tool; add significant overhead; use psutil for production memory metrics
- • Memory size analysis — objgraph counts objects not their sizes; for memory size use sys.getsizeof() or pympler
- • Automated memory management — objgraph is analysis tool; for fixing leaks, fix code; gc module handles automatic collection
Interface
Authentication
No auth — local memory analysis tool.
Pricing
objgraph is MIT licensed. Free for all use.
Agent Metadata
Known Gotchas
- ⚠ show_growth() first call always shows everything — objgraph.show_growth() baseline is zero on first call; first call output shows ALL objects as growth; call show_growth() once to establish baseline then again after the operation you're investigating: show_growth(); do_work(); show_growth() — second call shows true growth
- ⚠ gc.collect() required before analysis — Python garbage collector may not have run; agents must gc.collect() before objgraph analysis to ensure cycles are collected before counting; otherwise: objects in unreachable cycles appear as potential leaks but would be collected on next GC cycle
- ⚠ graphviz required for visual graphs — show_backrefs(obj) and show_refs(obj) generate dot graphs requiring graphviz installed; without graphviz: raises RuntimeError or generates empty output; install: brew install graphviz (macOS) or apt-get install graphviz (Linux); text output via output=io.StringIO() doesn't need graphviz
- ⚠ objgraph itself holds references — importing objgraph and calling functions adds objgraph's own objects to the heap; show_growth() shows growth including objgraph internals; agent code analyzing leaks should call gc.collect() and ignore objgraph types in results
- ⚠ get_leaking_objects() is slow for large heaps — traverses all Python objects to find those with no referrers; on heaps with millions of objects (ML models, large datasets): takes seconds; run only when debugging, not in normal operation; consider psutil.Process().memory_info() for production monitoring
- ⚠ show_most_common_types() counts all Python objects — includes Python internals (frames, cells, code objects); agent code reading output must distinguish application objects from interpreter overhead; focus on application types: dict, list, custom classes; 'frame' and 'function' type growth usually indicates call stack depth not leaks
Alternatives
Full Evaluation Report
Comprehensive deep-dive: security analysis, reliability audit, agent experience review, cost modeling, competitive positioning, and improvement roadmap for objgraph.
AI-powered analysis · PDF + markdown · Delivered within 30 minutes
Package Brief
Quick verdict, integration guide, cost projections, gotchas with workarounds, and alternatives comparison.
Delivered within 10 minutes
Score Monitoring
Get alerted when this package's AF, security, or reliability scores change significantly. Stay ahead of regressions.
Continuous monitoring
Scores are editorial opinions as of 2026-03-06.