Overview of objgraph
masterobjgraph is a Python module designed to let you visually explore Python object graphs, which is particularly useful for hunting memory leaks.repository·master·Indexed 21 days ago
https://github.com/mgedmin/objgraphA Python module used to visually explore and navigate Python object graphs, primarily for debugging and identifying memory leaks. It supports Python 2.7 and 3.5+ and integrates with Graphviz and xdot for visual graph rendering.
objgraph is a Python module designed to let you visually explore Python object graphs, which is particularly useful for hunting memory leaks.The project supports Python 2.7 and 3.5+. You can use tox to run the test suite across all supported versions automatically.
tox -p autoTo fully rebuild the project documentation and all associated images, run:
make clean images docsNote: When committing changes, use git checkout -- docs/*.png for images that haven't changed significantly, as memory addresses in images often change between runs.
To start contributing to objgraph, clone the repository and run the test suite to ensure everything is working correctly.
# Clone the source
git clone https://github.com/mgedmin/objgraph
# Run the test suite
make testgit clone https://github.com/mgedmin/objgraph
make testTo see how much of the code is covered by the existing (mostly smoke) tests, use the coverage tool via the provided Makefile command.
To view a text-based summary:
make coverageTo generate an HTML report:
make coverage
coverage htmlThen browse the results in htmlcov/index.html.
You can install objgraph using pip from PyPI.
pip install objgraphTo draw pretty graphs, you must have graphviz installed on your system. For interactive use, it is recommended to install xdot. objgraph will automatically look for xdot in your PATH.
pip install xdotThe PyPI long description is generated by concatenating README.rst and CHANGES.rst. You can preview how this will look using the make command:
make preview-pypi-descriptionAll new functions must have a PEP-257 compliant docstring. When adding them, ensure you add the appropriate autodoc directive to objgraph.txt.
Docstring Formatting Rules:
""" should not be preceded by a blank line.def do_something():
"""Do something.
Return something valuable.
"""def do_something():
"""Do something.
Return something valuable.
Example:
>>> do_something()
42
"""def do_something():
"""Do something.
Return something valuable.
"""Since many tests are verified by inspecting generated images, you can debug failures by comparing visual output. Use make images with a specific Python version and imgdiff to see the differences.
# Generate images for a specific Python version
make images PYTHON=pythonX.Y
# Configure git to use imgdiff for visual comparison
git config diff.imgdiff.command 'f() { imgdiff --eog -H $1 $2; }; f'
# Compare the generated images
git diff docs/*.pngmake images PYTHON=pythonX.Y
git config diff.imgdiff.command 'f() { imgdiff --eog -H $1 $2; }; f'
git diff docs/*.png