<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2016-08-31 17:51 GMT+02:00 Elvis Stansvik <span dir="ltr"><<a href="mailto:elvis.stansvik@orexplore.com" target="_blank">elvis.stansvik@orexplore.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p dir="ltr">HI Robert, </p><span class="">
<p dir="ltr">Den 31 aug. 2016 5:30 em skrev "Róbert Špir" <<a href="mailto:spir.robert@gmail.com" target="_blank">spir.robert@gmail.com</a>>:<br>
><br>
> Hi Elvis,<br>
><br>
> I noticed the same behavior before ( here is the topic <a href="http://vtk.1045678.n5.nabble.com/memory-leak-in-vtkStructuredPoints-or-am-I-doing-something-wrong-tt5738805.html" target="_blank">http://vtk.1045678.n5.nabble.<wbr>com/memory-leak-in-<wbr>vtkStructuredPoints-or-am-I-<wbr>doing-something-wrong-<wbr>tt5738805.html</a> )<br>
><br>
> Looks like it is the standard behavior of Linux (although very weird), since this is not happening in Windows or OS X.</p>
</span><p dir="ltr">Ah right, now I remember your post. I'll do some more testing to verify that this is actually what's happening in my case, but it likely is.</p></blockquote><div>I don't think this is the phenomenon I'm seeing. I tried opening the same dataset repeatedly in my app, and I got:<br><br>77 MB<br>368 MB<br>633 MB<br>860 MB<br>1003 MB<br>1171 MB<br>1345 MB<br>1518 MB<br>1691 MB<br>1858 MB<br>2029 MB<br>2201 MB<br>2371 MB<br>2543 MB<br><br></div><div>So the memory usage just keeps growing, despite my attempts to clean up before loading the dataset. This is from the RES (resident) column of top, and I don't think this is memory which can be reclaimed by the OS? That would show up in the VIRT (virtual) column I think.<br><br></div><div>So my question remains: Should I do something more to get a thorough cleanup, apart from removing the vtkVolume from the renderer and deleting it (by means of a smart pointer)?<br><br></div><div>Elvis<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<p dir="ltr">Thanks,<br>
Elvis</p><div class=""><div class="h5">
<p dir="ltr">><br>
> Best,<br>
><br>
> Robert<br>
><br>
> <br>
><br>
> From: vtkusers [mailto:<a href="mailto:vtkusers-bounces@vtk.org" target="_blank">vtkusers-bounces@vtk.<wbr>org</a>] On Behalf Of Elvis Stansvik<br>
> Sent: Wednesday, August 31, 2016 5:19 PM<br>
> To: VTK Users <<a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a>><br>
> Subject: [vtkusers] Memory not released when volumes are removed<br>
><br>
> <br>
><br>
> Hi all,<br>
><br>
> Before loading a new dataset into our app, I'd like to remove all existing volumes from the renderer, which I believe should lead to them being destroyed as well, since I have no other references to the volumes (currently).<br>
><br>
> What I tried was<br>
><br>
> // Remove all existing volumes<br>
> auto volumes = renderer()->GetVolumes();<br>
> volumes->InitTraversal();<br>
> for (int i = 0; i < volumes->GetNumberOfItems(); ++i) {<br>
> qDebug() << "removing volume";<br>
> vtkSmartPointer<vtkVolume> volume = volumes->GetNextVolume();<br>
> qDebug() << "before:" << volume->GetReferenceCount();<br>
> renderer()->RemoveVolume(<wbr>volume.GetPointer());<br>
> qDebug() << "after:" << volume->GetReferenceCount();<br>
> }<br>
><br>
> The output I get each time I load a new dataset (actually the same, but doing it repeatedly) and execution passes by this cleanup code is:<br>
><br>
> removing volume<br>
> before: 3<br>
> after: 1<br>
> removing volume<br>
> before: 3<br>
> after: 1<br>
> removing volume<br>
> before: 3<br>
> after: 1<br>
><br>
> Which sort of makes sense to me: Apparently the renderer holds two references to the volume, since the refcount goes down by 2 when I remove the volume from the renderer. The remaining reference is held by the vtkSmartPointer I created inside the loop.<br>
><br>
> But, what surprises me is that memory usage does not seem to go down when this code is executed. I would expect that when the scope of the for loop body is exited, the refcount will drop to zero, so the volume should be deleted. And I guess it probably is.<br>
><br>
> But looking at the memory usage when repeatedly loading datasets (and thus clearing the previous), the resident memory used by the app accumulates.<br>
><br>
> Must I somehow remove the mapper / underlying image data as well? I'm not holding any references to these, so I would have expected them to die along with the volume.<br>
><br>
> Helpful for any tips on why this cleanup is apparently not enough to avoid memory accumulation.<br>
><br>
> Thanks,<br>
><br>
> Elvis<br></p>
</div></div></blockquote></div><br></div></div>