[vtkusers] how to clean dataset?

Gennady Khokhorin gok at aerometric-ak.com
Thu Mar 20 15:56:32 EDT 2008


Hello, Wagner and all.
Still have problem with growing memory.
 
I have exact the same pipeline you did mention.
Debugging it found out that reference counter grows
from 1 to 3 at polydata->mapper connection:
this->m_dotMapper->SetInput(polyData);// ReferenceCount switched from 1
to 3
 
The same 3 times jump in values for app used memory.
Always tryed to modify polydata to vtkSmartPointer<vtkPolyData>
expecting auto dtor.

Did not try to delete actor or mapper for each new dataset yet because
vtkSDI sample works fine. Strange thing, polydata reference counter in
vtkSDI is not growing:
vtkPolyData *out = this->pvtkDataSetReader->GetOutput();
this->pvtkDataSetMapper->SetInput(out);// ReferenceCount is the same 1
So the memory is not growing with a big chunk of data.
 
Feels like I did not set "my" polydata correctly. vtkSDI sample is using
vtkParticleReader but 
its about 7 times slower then fscanf()
 
Could you or somebody bring more ideas to try, please.
 
Happy programming!
Gennady


________________________________

From: Wagner Sales [mailto:wsales at gmail.com] 
Sent: Wednesday, March 19, 2008 1:43 PM
To: Gennady Khokhorin
Subject: Re: [vtkusers] how to clean dataset?


Gennady,

I think your problem are about the VTK way to manage memory.
If you have a visualization pipeline ( eg:
polydata->mapper->actor->renderer ) you'll needs, i think:
1 - remove the actor from the renderer;
2 - delete the actor;
3 - delete the mapper;
4 - delete the poly.

Take in account that's the Delete() method in VTK gives no guaranties
that's your object will be deleted. Your object will be deleted only
when the reference counting will 0.
That's because your object aren't deleted, you are deleting mapper and
polydata, and not taking care about the actor.
And more one thing: take care if you are in a single cpp file without
class ( for example, main.cpp ) or in a class. In a class, you'll needs
to take in account the scope and delete the objects that's are class
member in the destructor.

Regards,

Wagner Sales



2008/3/19, Gennady Khokhorin <gok at aerometric-ak.com>: 

	Hello, all.
	I'm wonder what is a right way to clean data in mapper?
	For each new opening data set execution chain looks like that:
	
	
pcvtkSDIView->GetRenderer()->RemoveActor(this->m_pDotActor);
	..
	        // read data
	        vtkPolyData* polyData = vtkPolyData::New();
	        vtkPoints *points = vtkPoints::New();
	        polyData->SetPoints(points);
	        points->Delete();
	..
	        vtkElevationFilter* colorIt = vtkElevationFilter::New();
	        colorIt->SetInput(polyData);
	        vtkElevationFilter* colorIt = vtkElevationFilter::New();
	        vtkDataSetMapper *pDataSetMapper;
	        pDataSetMapper  = vtkDataSetMapper::New();
	..
	        pDataSetMapper->SetInput(colorIt->GetOutput());
	..
	        this->m_pDotActor->SetMapper(pDataSetMapper);
	..
	
pcvtkSDIView->GetRenderer()->AddActor(this->m_pDotActor);
	        // clear data
	        polyData->Delete();
	        pDataSetMapper->Delete();
	
	Every opening is increasing significantly app's used memory.
	
	Thank you in advance for suggestions.
	
	gok
	_______________________________________________
	This is the private VTK discussion list.
	Please keep messages on-topic. Check the FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
	Follow this link to subscribe/unsubscribe:
	http://www.vtk.org/mailman/listinfo/vtkusers
	





More information about the vtkusers mailing list