[Paraview-developers] how do I force garbage collection?

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Sun Mar 3 11:20:51 EST 2013


Josh,

I am sending you a patch is a separate email. Just to summarize for the
list:

- 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.

-  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.

- Use vtkSmartPointer<> or vtkWeakPointer<> when storing vtkObjects in STL
maps/list. Makes memory management a lot easier.

Utkarsh


On Fri, Feb 22, 2013 at 3:27 PM, Utkarsh Ayachit <
utkarsh.ayachit at kitware.com> wrote:

> Josh,
>
> 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.
>
> Utkarsh
>
>
> On Fri, Feb 22, 2013 at 12:22 PM, Joshua Murphy <
> Joshua.Murphy at lasp.colorado.edu> wrote:
>
>> Hello,
>>
>> 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.
>>
>> 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.
>>
>> 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.
>>
>>
>> Thanks,
>>
>> Josh
>>
>> Joshua J. Murphy
>> Computer Scientist
>> Laboratory for Atmospheric and Space Physics
>> University of Colorado, Boulder
>>
>>
>> _______________________________________________
>> Paraview-developers mailing list
>> Paraview-developers at paraview.org
>> http://public.kitware.com/mailman/listinfo/paraview-developers
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20130303/fb03af1d/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 16467 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview-developers/attachments/20130303/fb03af1d/attachment-0001.png>


More information about the Paraview-developers mailing list