{"id":5673,"library":"objgraph","title":"objgraph","description":"objgraph is a Python module that lets you visually explore Python object graphs. It helps in debugging, understanding memory usage, and finding memory leaks by drawing object reference graphs using Graphviz. The library is actively maintained with regular updates for Python version compatibility.","status":"active","version":"3.6.2","language":"en","source_language":"en","source_url":"https://github.com/mgedmin/objgraph","tags":["debugging","memory","profiling","graphviz","visualization","object-graph"],"install":[{"cmd":"pip install objgraph","lang":"bash","label":"Basic installation"},{"cmd":"pip install objgraph[ipython]","lang":"bash","label":"Installation with Graphviz Python package for IPython/Jupyter"}],"dependencies":[{"reason":"Required for generating and rendering DOT graph files into images (e.g., PNG) or for interactive viewing with tools like xdot.","package":"graphviz (system utility)","optional":false},{"reason":"Optional Python binding for Graphviz, used for inline display in environments like IPython/Jupyter notebooks. Included with `objgraph[ipython]` installation.","package":"graphviz (Python package)","optional":true}],"imports":[{"note":"The primary module containing all functions.","symbol":"objgraph","correct":"import objgraph"}],"quickstart":{"code":"import objgraph\n\ndef create_objects():\n    x = []\n    y = [x, [x], {'x_key': x}]\n    z = {'list_ref': y, 'dict_ref': {'inner_x': x}}\n    return x, y, z\n\nx, y, z = create_objects()\n\n# Show references reachable from 'y', save to a PNG\nobjgraph.show_refs([y], filename='sample-graph.png', max_depth=2)\nprint(\"Generated sample-graph.png showing references from 'y'\")\n\n# Show backreferences to 'x', save to a PNG\nobjgraph.show_backrefs([x], filename='sample-backref-graph.png', max_depth=2)\nprint(\"Generated sample-backref-graph.png showing backreferences to 'x'\")\n\n# Show most common types in memory\nprint(\"\\nMost common types in memory:\")\nobjgraph.show_most_common_types(limit=5)","lang":"python","description":"This quickstart demonstrates how to create some interconnected Python objects and then use `objgraph.show_refs` to visualize objects reachable from a given object, `objgraph.show_backrefs` to see what objects reference a specific object, and `objgraph.show_most_common_types` to get a summary of memory usage. For graph visualization, ensure the Graphviz system utility is installed and accessible in your PATH."},"warnings":[{"fix":"Ensure your Python environment is 3.8 or newer for `objgraph>=3.6.0`. Check `objgraph`'s `requires_python` metadata on PyPI for the exact minimum version supported by your target `objgraph` version.","message":"objgraph version 3.6.0 and later dropped support for Python 2.x and Python 3.7. Previous versions (e.g., 3.5.0) dropped Python 3.5 support, and 3.4.1 dropped 3.3 and 3.4.","severity":"breaking","affected_versions":">=3.6.0 (for Python 2.x, 3.7); >=3.5.0 (for Python 3.5); >=3.4.1 (for Python 3.3, 3.4)"},{"fix":"Install Graphviz on your operating system (e.g., `sudo apt-get install graphviz` on Debian/Ubuntu, `brew install graphviz` on macOS, or download from graphviz.org). Optionally, install the Python `graphviz` package (`pip install graphviz` or `pip install objgraph[ipython]`) for better integration, especially in Jupyter.","message":"Drawing object graphs with `show_refs()` or `show_backrefs()` requires the external Graphviz system utility to be installed and available in your system's PATH. Without it, image generation will fail.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Upgrade to objgraph 3.5.0 or later to ensure the `filename` argument behaves as expected, or omit `filename` to leverage the interactive viewer if `xdot` is installed.","message":"In IPython/Jupyter notebooks, before version 3.5.0, explicitly passing a `filename` argument to `show_refs()` or `show_backrefs()` might still trigger inline graph display instead of only saving to the specified file.","severity":"gotcha","affected_versions":"<3.5.0"},{"fix":"Install `xdot` (`pip install xdot` or via system package manager) and call `show_refs()` or `show_backrefs()` without a `filename` argument.","message":"For interactive viewing of graphs without saving to a file, `objgraph` can integrate with `xdot`. You'll need to install `xdot` separately (`pip install xdot` or system-wide) and omit the `filename` argument from `show_refs`/`show_backrefs`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}