In this section, we will discuss a few more tools that will aid the programmer in debugging memory leaks and also enable him to visualize his objects and their relations.
Objgraph (object graph) is a Python object visualization tool that makes use of the graphviz
package to draw object reference graphs.
It is not a profiling or instrumentation tool but can be used along with such tools to visualize object trees and references in complex programs while hunting for elusive memory leaks. It allows you to find out references to objects to figure out what references are keeping an object alive.
As with almost everything in the Python world, it is installable via pip
:
$ pip3 install objgraph
However objgraph is really useful only if it can generate graphs. Hence we need to install the graphviz
package and the xdot
tool.
In a Debian/Ubuntu system, you will install this as follows:
$ sudo apt install graphviz xdot -y
Let's look at a simple example of using objgraph
to find out hidden...