Debugging Memory Leaks
This page provides information for how to locate and fix memory leaks in VisIt.
 Debugging VTK Memory Leaks In VisIt
One type of memory leak in VisIt often results from VTK objects that are not properly deleted.
 Determining if you have a leak
If the engine crashes or thrashes, run with top, looking for Visit's processes named engine_ser, viewer, gui, mdserver
Get a memory profile with valgrind:
visit -valgrind "--tool=massif --format=html" engine_ser
 VTK Debug Methods
vtkObject (the base class of all vtk objects) provides access to valuable memory debugging info via the DebugOn() method. In VisIt these debug messages are logged at debug level 1, so to access them you must run with debug logs on:
visit -debug 1
(See -debug info page for more info on debug logs)
You can also use the -vtk-debug option:
 VisIt's Vtk Debug Mode
To run in vtk debug mode invoke VisIt with the -vtk-debug flag:
This mode enables debug level 1 (if not already enabled) and calls DebugOn() on vtk objects created between pipeline stages and created from databases.
Logging these events tests that the avt Pipeline infrastructure is behaving properly.
Manually examining vtk debug messages quickly becomes tedious, so to ease the pain the vtk_debug_trace.py script was developed. This script processes VisIt debug logs extracting vtk debug messages per object using the object's address as a unique key. It creates an xml file that lists possible leaks and logs each vtk debug event per object.
To run use script, pass it a VisIt engine log file and specify an output file:
vtk_debug_trace.py engine_ser.1.log trace_result.xml
You can view the xml output file formated with vtk_debug_trace_style.xsl style sheet using a modern web browser:
The leaks section lists the number of objects allocated by type and lists each object's address, type, and reference count.
The vtk objects section details each object and all associated vtk debug events.(This includes objects that have been deleted)
(vtk_debug_trace.py and vtk_debug_trace_style.xsl are located in src/tools/vtk_debug)
- In -vtk-debug mode, VisIt filters frequent messages (such access to a single tuple's values) to spare the file system and cut down on i/o the performance hit.
- The -vtk-debug only flags datasets and data arrays created between pipeline stages. To debug datasets created inside a filter, you must call DebugOn() on each vtk object of interest.
- To detect true leaks you must delete your plot. Recall VisIt keeps vtk dataset around for querying/viewing.
- When running in parallel debug logs may not flush to disc immediately - so double check that your logs reflect the actual state of VisIt.