Difference between revisions of "Slicer3:VTK Leak Debugging"

From NAMIC Wiki
Jump to: navigation, search
 
m (Text replacement - "http://www.slicer.org/slicerWiki/index.php/" to "https://www.slicer.org/wiki/")
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
If you are getting leaks for a vtkObject but can't figure out where it's coming from, you can try making a change to the constructor for that class and checking the debug output (warning, it can be verbose).  What you will see from the following type of change is instances that are created but never destroyed.  Then you can add other debug statements in your code and narrow down which instances aren't being deleted.
+
<big>'''Note:''' We are migrating this content to the slicer.org domain - <font color="orange">The newer page is [https://www.slicer.org/wiki/Slicer3:VTK_Leak_Debugging  here]</font></big>
 
 
Add this at the beginning of the constructor:
 
this->DebugOn();
 
vtkDebugMacro("constructing");
 
 
 
and this in the destructor:
 
vtkDebugMacro("destructing");
 
 
 
For example, these changes helped me find an extra instance of vtkPoints
 
 
 
<pre>
 
// Construct object with an initial data array of type float.
 
vtkPoints::vtkPoints(int dataType)
 
{
 
this->DebugOn();
 
vtkDebugMacro("constructing");
 
  this->Data = vtkFloatArray::New();
 
  this->Data->Register(this);
 
  this->Data->Delete();
 
  this->SetDataType(dataType);
 
 
 
  this->Data->SetNumberOfComponents(3);
 
 
 
  this->Bounds[0] = this->Bounds[2] = this->Bounds[4] = 0.0;
 
  this->Bounds[1] = this->Bounds[3] = this->Bounds[5] = 1.0;
 
}
 
 
 
vtkPoints::~vtkPoints()
 
{
 
vtkDebugMacro("destructing");
 
  this->Data->UnRegister(this);
 
}
 
</pre>
 

Latest revision as of 18:07, 10 July 2017

Home < Slicer3:VTK Leak Debugging

Note: We are migrating this content to the slicer.org domain - The newer page is here