Skip to content

VTK_DEBUG_LEAKS: Add ability to store stack traces at VTK object allocation

VTK_DEBUG_LEAKS is great for identifying when a VTK object is leaking, but does not really help identify which objects are being leaked. This commit adds support for registering VTK objects and keeping track of the stack at the time of their creation. The top of the recorded stack corresponds to the New() command used to allocate the object.

At the end of program execution, any remaining objects that have not been deleted will be printed to standard error along with the stack trace at the time of their allocation.

Because storing a trace for every allocated VTK object may be prohibitively expensive in both terms of time and memory, traces are only recorded for VTK classes listed in the environment variable VTK_DEBUG_LEAKS_TRACE_CLASSES. Multiple VTK classes may be defined in this environment variable in a comma-separated list.

Merge request reports