[vtkusers] growing RAM memory

Xiaofeng Z xf10036 at hotmail.com
Sun May 22 12:01:50 EDT 2011


Is "ren" a smart pointer?
 
If so, you're two code fragment should be equivalent, unless, there's a bug with vtkSmartPointer.  In fact, with smart pointer, you don't even need ren = NULL or ren->Delete() (the purpose of using smart pointer).

On the other hand, as long as your Render window keeps a reference to the object pointed by ren, that object will not be deallocated.  You ended up accumulating renderers in the render window.
 
Your approach of calling RemoveRenderer from RenderWindow is the right path.  You must make sure that you always use smart pointer in order for the gabage collector to work correctly.
 
HTH!

Xiaofeng

 


Date: Sun, 22 May 2011 13:03:35 +0200
From: greenlander1986 at gmail.com
To: chasank at gmail.com
CC: vtkusers at vtk.org
Subject: Re: [vtkusers] growing RAM memory

When I use 

        ren = NULL;        ren = vtkSmartPointer<vtkRenderer>::New();        ren->SetBackground(1,1,1);        ren->AddActor(actor);        widget->GetRenderWindow()->AddRenderer(ren);

it works but, memory is grown again. 

when I use 

        ren->Delete();        ren = vtkSmartPointer<vtkRenderer>::New();        ren->SetBackground(1,1,1);        ren->AddActor(actor);        widget->GetRenderWindow()->AddRenderer(ren);
it doesnt work.

I am desperate. :(


2011/5/22 G G <greenlander1986 at gmail.com>

I am trying now. In VTK examples Examples\GUI\Qt\Events is in global scope only vtkRenderer... I have tried according this, but it crash in 
        cout<<"bla"<<endl;        ren = NULL;
        ren->SetBackground(1,1,1);        ren->AddActor(actor);        widget->GetRenderWindow()->AddRenderer(ren);        cout<<"ups"<<endl;"bla" is written, but "ups" not. I have in all important method 
vtkSmartPointer<vtkRenderer> ren

inicialization I do only ones, it is problem?






2011/5/21 G G <greenlander1986 at gmail.com>

Thank you, I try it. And post here solution



2011/5/21 chasank <chasank at gmail.com>




My suggestion is,
 if you do not need more than one renderer and RenderWindow
 - Define them in a global scope,
 - And before each call to the widgetInicialization method, set them to the
NULL
 - in widgetInicialization method, Re-create them, set the values
 - Lastly update your widget object.

--
View this message in context: http://vtk.1045678.n5.nabble.com/growing-RAM-memory-tp4346305p4415624.html



Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers




_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ Follow this link to subscribe/unsubscribe: http://www.vtk.org/mailman/listinfo/vtkusers 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110522/7cdbb5fc/attachment.htm>


More information about the vtkusers mailing list