[vtkusers] memory leak in windows/mfc app

Finegan Thomas-QTF001 T.Finegan at motorola.com
Tue Feb 24 15:59:06 EST 2004


I'm using vtk (compiled as DLLs) in an MFC application on Windows. When I run the program in the Visual Studio 2003 debugger, it reports a single block of memory of 5200 bytes that was leaked. The following function is in my MFC view class, and when I comment it out, the leak disappears. However, I'm deleting the renderer, render window and render window interactor before the app. exits.

void CViewerView::Pipeline()
{
	CViewerDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);

	TRACE("ViewerView::Pipeline %ld parts!\n", pDoc->m_partsData.size());
	ren->RemoveAllProps();
	for (std::vector<vtkPolyData*>::iterator it = pDoc->m_partsData.begin(); it != pDoc->m_partsData.end(); ++it) {
		// Link the mapper
		vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
		mapper->SetInput((*it));
		mapper->SetColorModeToMapScalars();
		mapper->SetScalarRange(-1,1);
	  
		// Link the actor
		vtkActor *actor = vtkActor::New();
		actor->SetMapper(mapper);
		mapper->Delete();

		// Add it to the renderer
		ren->AddActor(actor);
		actor->Delete();
	}
	this->ren->ResetCamera();
  TRACE("ViewerView::Pipeline Done\n");
}

Any ideas where this code is causing the leak??



More information about the vtkusers mailing list