<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Is "ren" a smart pointer?<BR>
&nbsp;<BR>
If so, you're two code fragment should be equivalent, unless, there's a bug with vtkSmartPointer.&nbsp; In fact, with smart pointer, you don't even need ren = NULL or ren-&gt;Delete() (the purpose of using smart pointer).<BR><BR>
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.&nbsp; You ended up accumulating renderers in the render window.<BR>
&nbsp;<BR>
Your approach of calling RemoveRenderer from RenderWindow is the right path.&nbsp; You must make sure that you always use smart pointer in order for the gabage collector to work correctly.<BR>
&nbsp;<BR>
HTH!<BR>
<BR>Xiaofeng<BR><BR>&nbsp;<BR>

<HR id=stopSpelling>
Date: Sun, 22 May 2011 13:03:35 +0200<BR>From: greenlander1986@gmail.com<BR>To: chasank@gmail.com<BR>CC: vtkusers@vtk.org<BR>Subject: Re: [vtkusers] growing RAM memory<BR><BR>When I use <BR><BR><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ren = NULL;</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ren = vtkSmartPointer&lt;vtkRenderer&gt;::New();</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ren-&gt;SetBackground(1,1,1);</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ren-&gt;AddActor(actor);</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; widget-&gt;GetRenderWindow()-&gt;AddRenderer(ren);</SPAN><BR><BR>it works but, memory is grown again. <BR><BR>when I use <BR><BR><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ren-&gt;Delete();</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ren = vtkSmartPointer&lt;vtkRenderer&gt;::New();</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ren-&gt;SetBackground(1,1,1);</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ren-&gt;AddActor(actor);</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; widget-&gt;GetRenderWindow()-&gt;AddRenderer(ren);</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN style="FONT-FAMILY: courier new,monospace"></SPAN><BR>it doesnt work.<BR><BR>I am desperate. :(<BR><BR>
<DIV class=ecxgmail_quote>2011/5/22 G G <SPAN dir=ltr>&lt;<A href="mailto:greenlander1986@gmail.com">greenlander1986@gmail.com</A>&gt;</SPAN><BR>
<BLOCKQUOTE style="BORDER-LEFT: #ccc 1px solid; PADDING-LEFT: 1ex" class=ecxgmail_quote>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 <BR><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; cout&lt;&lt;"bla"&lt;&lt;endl;</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ren = NULL;</SPAN>
<DIV class=ecxim><BR style="FONT-FAMILY: courier new,monospace"><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ren-&gt;SetBackground(1,1,1);</SPAN><BR style="FONT-FAMILY: courier new,monospace"></DIV><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ren-&gt;AddActor(actor);</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; widget-&gt;GetRenderWindow()-&gt;AddRenderer(ren);</SPAN><BR style="FONT-FAMILY: courier new,monospace"><SPAN style="FONT-FAMILY: courier new,monospace">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; cout&lt;&lt;"ups"&lt;&lt;endl;</SPAN><BR style="FONT-FAMILY: courier new,monospace">"bla" is written, but "ups" not. I have in all important method <BR>vtkSmartPointer&lt;vtkRenderer&gt; ren<BR><BR>inicialization I do only ones, it is problem?
<DIV>
<DIV></DIV>
<DIV class=h5><BR><BR><BR>
<DIV class=ecxgmail_quote>2011/5/21 G G <SPAN dir=ltr>&lt;<A href="mailto:greenlander1986@gmail.com">greenlander1986@gmail.com</A>&gt;</SPAN><BR>
<BLOCKQUOTE style="BORDER-LEFT: #ccc 1px solid; PADDING-LEFT: 1ex" class=ecxgmail_quote>Thank you, I try it. And post here solution<BR><BR>
<DIV class=ecxgmail_quote>
<DIV>2011/5/21 chasank <SPAN dir=ltr>&lt;<A href="mailto:chasank@gmail.com">chasank@gmail.com</A>&gt;</SPAN><BR></DIV>
<DIV>
<DIV></DIV>
<DIV>
<BLOCKQUOTE style="BORDER-LEFT: #ccc 1px solid; PADDING-LEFT: 1ex" class=ecxgmail_quote>My suggestion is,<BR>&nbsp;if you do not need more than one renderer and RenderWindow<BR>&nbsp;- Define them in a global scope,<BR>&nbsp;- And before each call to the widgetInicialization method, set them to the<BR>NULL<BR>&nbsp;- in widgetInicialization method, Re-create them, set the values<BR>&nbsp;- Lastly update your widget object.<BR><FONT color=#888888><BR>--<BR>View this message in context: <A href="http://vtk.1045678.n5.nabble.com/growing-RAM-memory-tp4346305p4415624.html" target=_blank>http://vtk.1045678.n5.nabble.com/growing-RAM-memory-tp4346305p4415624.html</A><BR></FONT>
<DIV>
<DIV></DIV>
<DIV>Sent from the VTK - Users mailing list archive at Nabble.com.<BR>_______________________________________________<BR>Powered by <A href="http://www.kitware.com/" target=_blank>www.kitware.com</A><BR><BR>Visit other Kitware open-source projects at <A href="http://www.kitware.com/opensource/opensource.html" target=_blank>http://www.kitware.com/opensource/opensource.html</A><BR><BR>Please keep messages on-topic and check the VTK FAQ at: <A href="http://www.vtk.org/Wiki/VTK_FAQ" target=_blank>http://www.vtk.org/Wiki/VTK_FAQ</A><BR><BR>Follow this link to subscribe/unsubscribe:<BR><A href="http://www.vtk.org/mailman/listinfo/vtkusers" target=_blank>http://www.vtk.org/mailman/listinfo/vtkusers</A><BR></DIV></DIV></BLOCKQUOTE></DIV></DIV></DIV><BR></BLOCKQUOTE></DIV><BR></DIV></DIV></BLOCKQUOTE></DIV><BR><BR>_______________________________________________ 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                                               </body>
</html>