[vtkusers] Why these leaks reported/happens?
Alex Malyushytskyy
alexmalvtk at gmail.com
Tue Jan 12 07:04:05 EST 2010
I am using VTK on Windows XP 64 bit, compiled with msvc2005 (SP1) and Qt4.6
I have mostly every instance of vtkObject I create reported as a leak.
For example
a) If following function is called twice I get 2 instance of
vtkSTLReader reported leaking.
vtkPolyData* ubAbstractStructurePresentation::createPolyDataFromStlFile(
const QString& fileName )
{
vtkPolyData* poly = NULL;
Q_ASSERT( !fileName.isEmpty() );
if( ! fileName.isEmpty() )
{
vtkSmartPointer<vtkSTLReader> sr = vtkSmartPointer<vtkSTLReader>::New();
QByteArray byteArray = QFile::encodeName ( fileName );
sr->SetFileName( byteArray.data() );
vtkSmartPointer<vtkGeometryFilter> filter = createGeometryFilter();
filter->SetInputConnection( 0, sr->GetOutputPort( 0 ) );
filter->Update();
// make poly forget about the way it was created and release all the
vtkObjects
poly = filter->GetOutput();
poly->Register(NULL);
poly->SetSource(NULL);
#ifdef DEBUG_POLY_DATA_MEMORY_LEAKS
poly->DebugOn();
#endif
}
return poly;
}
I expected that sr will destroy associated vtkSTLReader as son it goes
out of scope, are my expectation wrong?
b) The instance of the my widget has a smart pointer to
vtkEventQtSlotConnect as a member .
Even though I checked that my widget is destroyed and it seems that my
code is pretty simple, vtkEventQtSlotConnect is stil reported as a
leak:
// declaration of the class member in header file:
vtkSmartPointer<vtkEventQtSlotConnect> Connections;
// only function touching Connections
void model3dView::initVtkConnections()
{
Connections = vtkEventQtSlotConnect::New();
// connect window enter event to radio button slot
Connections->Connect( this->GetRenderWindow()->GetInteractor(),
vtkCommand::EndPickEvent, this, SLOT( onEndPickEvent() ));
Connections->Connect( this->GetRenderWindow()->GetInteractor(),
vtkCommand::StartEvent, this, SLOT( onStartPickEvent() ));
Connections->Connect(
this->GetRenderWindow()->GetInteractor()->GetInteractorStyle(),
InteractionModeSetStartEvent, this, SLOT(
onInteractionModeChangedByInteractor() ));
}
c) Am I doing something wrong? Can debug leak option be used with
smart pointers?
Thanks in advance,
Alex
More information about the vtkusers
mailing list