<div dir="ltr">Hi Robert,<div><br></div><div>I took a look at your test case (thanks, btw -- these help a lot!) and while I can reproduce the results, it appears that linux is just caching the memory for the process, not leaking it.</div><div><br></div><div>I modified your script to do 50 cycles of load/clears, with this result:</div><div><br></div><div><div>./vtkbug                                                                                                                                </div><div>Press 1 for zebra, 2 for phallucia                                                                                                                                        </div><div>1                                                                                                                                                                         </div><div>Data loaded: 352 MB in use.                                                                                                                                               </div><div>Data cleared: 248 MB in use.                                                                                                                                              </div><div>Data loaded: 378 MB in use.                                                                                                                                               </div><div>Data cleared: 378 MB in use.                                                                                                                                              </div><div>Data loaded: 352 MB in use.                                                                                                                                               </div><div>Data cleared: 352 MB in use.                                                                                                                                              </div><div>Data loaded: 352 MB in use.                                                                                                                                               </div><div>Data cleared: 352 MB in use.</div><div>[snipped 45 load/clears]</div><div>Data loaded: 378 MB in use.</div><div>Data cleared: 378 MB in use.</div></div><div><br></div><div>While the memory is still marked as reserved by the process, it doesn't grow, and the 'leaked' memory is reused by later allocations.</div><div><br></div><div><div>I also verified that the dataset destructors are being called at the appropriate times, and valgrind confirms that no memory is leaking at exit.</div></div><div><br></div><div>I did a quick google search for clearing linux memory caches, and it appears that it may be possible to instruct linux to drop the cache if this is causing problems, but I suspect the operating system will reclaim cached memory when it starts running out. Unless you start seeing memory allocations fail or excessive swapping, this can likely be ignored.</div><div><br></div><div>HTH,</div><div>Dave</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 21, 2016 at 2:36 AM, RobertS <span dir="ltr"><<a href="mailto:spir.robert@gmail.com" target="_blank">spir.robert@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello all,<br>
I'm doing visualization of series of 3D volumes stored in VTK files. First I<br>
load all vtk files to vector of vtkStructuredPoints using this simple code<br>
inside cycle<br>
<br>
vtkSmartPointer<vtkStructuredPointsReader> reader =<br>
vtkSmartPointer<vtkStructuredPointsReader>::New();<br>
reader->SetFileName(filename);<br>
reader->Update();<br>
ptsCopy = vtkSmartPointer<vtkStructuredPoints>::New();<br>
ptsCopy->DeepCopy(reader->GetOutput());<br>
loadedPoints.push_back(ptsCopy);<br>
reader->CloseVTKFile();<br>
<br>
then when I want to change the dataset I just call loadedPoints.clear() and<br>
start loading other vtk files.<br>
Now on windows, everything goes as expected, by calling .clear() memory get<br>
freed. This is not the case in linux, here the memory is stil occupied and<br>
since I'm working with very large datasets (>12GB) this is a serious<br>
problem.<br>
Now another interesting thing is, that with some datasets the memory gets<br>
cleared even in linux, but with some others it doesn't...<br>
I'm using VTK 7.0 compiled from source, vs2015 in windows, gcc6.1 in linux<br>
<br>
I made a small project that only loads the vtk files to vector and then<br>
clears it, displaying amount of used memory in between. I can reproduce the<br>
memory leak with this code in linux, in windows it clears the memory.<br>
<a href="http://tesla.math.sk/vtkbug.7z" rel="noreferrer" target="_blank">http://tesla.math.sk/vtkbug.7z</a><br>
Here you can download two datasets, zebra is causing the leak, phallusia is<br>
not<br>
<a href="http://tesla.math.sk/zebra.7z" rel="noreferrer" target="_blank">http://tesla.math.sk/zebra.7z</a><br>
<a href="http://tesla.math.sk/phallusia.7z" rel="noreferrer" target="_blank">http://tesla.math.sk/phallusia.7z</a><br>
<br>
Thanks for any help<br>
<br>
Robert Spir PhD<br>
Department of Mathematics<br>
Slovak University of Technology<br>
Radlinskeho 11<br>
813 68 Bratislava<br>
Slovakia<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/memory-leak-in-vtkStructuredPoints-or-am-I-doing-something-wrong-tp5738805.html" rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.com/memory-leak-in-vtkStructuredPoints-or-am-I-doing-something-wrong-tp5738805.html</a><br>
Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br></div>