<div dir="ltr">Hi John,<div><br></div><div style>I started removing from some places where it is not necessary. vtkDataObject and subclasses for example. It hasn't made it to master yet but it will before VTK 6.0. Any other place where it is not absolutely necessary, we should take it out. This should leave a few places including some rendering classes and pipeline connectivity (i.e. setting input to filters). That one is very hard to get rid of. Impossible without changing the API significantly. However, there are other ways of executing a filter without setting the input so we may be able to live with it. I CC'ed VTK developers since this is a broader VTK discussion. How do folks feel about garbage collection?</div>

<div style><br></div><div style>-berk</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 4, 2013 at 4:18 AM, Biddiscombe, John A. <span dir="ltr"><<a href="mailto:biddisco@cscs.ch" target="_blank">biddisco@cscs.ch</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-GB" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Utkarsh - sorry for hijacking this tread. (Well, actually I’m not sorry, but I have to say that out of politeness)<u></u><u></u></span></p>


<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I have some big problems with the garbage collection. The main problem is that it simply isn’t needed in 99.9% of the code in vtk/paraview, but unfortunately
 is used throughout. There are some actor/mapper/renderer places where it is useful, but everywhere else it is a huge waste of resources/time.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I have some structures like a SIL populated with a tree of several thousand objects, it takes minutes to delete (when debugging is enabled for sure) (and construction
 is slower than necessary). In my own code, I have had to resort to replacing all calls to Delete with FastDelete and never yet had any problem with dangling references or double deletion. I am considering modifying the pv source in places like the SIL to also
 use fastdelete.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Could we consider Making non garbage collection/deletion the default, and only using it in places where we know circular reference loops are likely?<u></u><u></u></span></p>


<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">JB<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> <a href="mailto:paraview-developers-bounces@paraview.org" target="_blank">paraview-developers-bounces@paraview.org</a>
 [mailto:<a href="mailto:paraview-developers-bounces@paraview.org" target="_blank">paraview-developers-bounces@paraview.org</a>] <b>On Behalf Of </b>Utkarsh Ayachit<br>
<b>Sent:</b> 03 March 2013 17:21<br>
<b>To:</b> Joshua Murphy<br>
<b>Cc:</b> <a href="mailto:paraview-developers@paraview.org" target="_blank">paraview-developers@paraview.org</a><br>
<b>Subject:</b> Re: [Paraview-developers] how do I force garbage collection?<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:36.0pt"><u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-left:36.0pt">Josh,<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt">I am sending you a patch is a separate email. Just to summarize for the list:<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt">- When writing plugins/readers, turn on CMake flag VTK_DEBUG_LEAKS. ParaView will start dumping messages about any VTK objects that are not cleaned up while exiting the application. That helps to catch stray VTK-object
 references early in the development process.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt">-  Use vtkNew<> for creating local VTK objects in methods. Developers often forget to call the Delete() before exiting the method esp. when complicated if/else/swicthes are involved.<u></u><u></u></p>


</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt">- Use vtkSmartPointer<> or vtkWeakPointer<> when storing vtkObjects in STL maps/list. Makes memory management a lot easier.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt">Utkarsh<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<u></u> <u></u></p>
<div>
<p class="MsoNormal" style="margin-left:36.0pt">On Fri, Feb 22, 2013 at 3:27 PM, Utkarsh Ayachit <<a href="mailto:utkarsh.ayachit@kitware.com" target="_blank">utkarsh.ayachit@kitware.com</a>> wrote:<u></u><u></u></p>


<div>
<p class="MsoNormal" style="margin-left:36.0pt">Josh,<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt">VTK/ParaView uses reference counting. So as long as a there's a reference held to any dataobject, Delete() is not going to release it. Barring cycles, a quick way to see if Delete() will result in clearing the
 object, is to look it it's ReferenceCount member variable before calling Delete(). However if you're passing the data allocated as output from your filters then the reference maybe getting held by the pipeline beyond your control. If you can share the code,
 I can see if I can explain why the memory may not be getting released.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt">Utkarsh<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt">On Fri, Feb 22, 2013 at 12:22 PM, Joshua Murphy <<a href="mailto:Joshua.Murphy@lasp.colorado.edu" target="_blank">Joshua.Murphy@lasp.colorado.edu</a>> wrote:<u></u><u></u></p>


</div>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif"">Hello,<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif"">I am writing a cache system for my reader, and I am trying to figure out how to force a garbage collection after I dump my cache.<u></u><u></u></span></p>


</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif"">Does anyone know how to force ParaView to collect garbage?  Currently after I purge my cache (I am calling Delete() on all of the objects and destroying
 the remainder of the cache map) the system memory does not free up… ParaView remains in control of all of the memory for the dumped cache items, and when the new cache is introduced, the memory usage just keeps going up.<u></u><u></u></span></p>


</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif"">I suppose it is possible that I am missing some fundamental understanding of how ParaView and VTK manage memory, so if someone could help that
 would be great.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif"">Thanks,<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif"">Josh<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
</div>
<div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif""><img border="0" width="149" height="51" src="cid:image001.png@01CE18C1.85AE9910"><u></u><u></u></span></p>


</div>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif"">Joshua J. Murphy<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif"">Computer Scientist<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif"">Laboratory for Atmospheric and Space Physics<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif"">University of Colorado, Boulder<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="font-size:10.5pt;font-family:"Calibri","sans-serif""><u></u> <u></u></span></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-left:36.0pt"><u></u> <u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
_______________________________________________<br>
Paraview-developers mailing list<br>
<a href="mailto:Paraview-developers@paraview.org" target="_blank">Paraview-developers@paraview.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/paraview-developers" target="_blank">http://public.kitware.com/mailman/listinfo/paraview-developers</a><u></u><u></u></p>
</blockquote>
</div>
<p class="MsoNormal" style="margin-left:36.0pt"><u></u> <u></u></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:36.0pt"><u></u> <u></u></p>
</div>
</div>
</div>

<br>_______________________________________________<br>
Paraview-developers mailing list<br>
<a href="mailto:Paraview-developers@paraview.org">Paraview-developers@paraview.org</a><br>
<a href="http://public.kitware.com/mailman/listinfo/paraview-developers" target="_blank">http://public.kitware.com/mailman/listinfo/paraview-developers</a><br>
<br></blockquote></div><br></div>