R: [vtkusers] Delete problems

Dominik Szczerba domi at vision.ee.ethz.ch
Sat Jul 15 06:01:22 EDT 2006


No I am not familiar with this problems. Do you use smart pointers?
regards,
Dominik

Lazzarato Dr. Gianni wrote:
> Hi David, Hi Dominik,
> 
> I have similar problem with memory and vtk 5.
> In a short pipeline with some filters I have a strange memory leak problem.
> ( I carefully follow all the guidelines: new, delete, register, unregister
> etc.).
> This portion of code cause a memory leak: it is contained in a class derived
> from vtkPolyDataAlgorithm and using new pipeline schema.
> 
> 
> ----------------------------------------------------
>   if (renderer->HasViewProp(Actor))
> 	 {
> 	   Actor ->Modified();
>        }
> 	else
> 	  {
> 	  renderer->AddViewProp(Actor);
> 	  }
> 	  renderer->Render();
> ----------------------------------------------------
> 
> Actor is added correctly first time,
> in next interactions actor is correctly modified by the pipeline and
> updated, but memory use increase for each interaction....each time I have a
> call  to Actor->Modified() system memory usage increase. Why??? 
> 
> Thanks for suggestions.
> 
> Gianni Lazzarato
> 
>  
> 
> 
> 
> 
> 
> -----Messaggio originale-----
> Da: vtkusers-bounces+lazzadrgi=libero.it at vtk.org
> [mailto:vtkusers-bounces+lazzadrgi=libero.it at vtk.org] Per conto di David
> Cole
> Inviato: venerdì 14 luglio 2006 18.09
> A: Dominik Szczerba
> Cc: vtkusers vtkusers
> Oggetto: Re: [vtkusers] Delete problems
> 
> Any "New" calls should have corresponding "Delete" calls. Any "Register" 
> calls should have corresponding "UnRegister" calls. And any reference 
> loops need to be broken by setting one of the pointer variables involved 
> to NULL or 0.
> 
> Order is largely irrelevant except in the reference loop case. Sometimes 
> it's important to know which part of a reference loop needs to go away 
> first. Perhaps you need to force a bunch of objects to go away before a 
> window is destroyed (for example).
> 
> That's the beauty of reference counted systems: order doesn't matter as 
> much as balance does...
> 
> If you can't figure out where there's a missing Delete or UnRegister 
> call, look for loops in pointer members (does your pipeline have a 
> feedback loop??) It sometimes helps to draw a diagram of the pipeline. 
> Or you could try simplifying it bit by bit and see when the leak goes 
> away... Then start adding things back in until the leak comes back. That 
> should point out where to look in the code...
> 
> 
> Hope this helps,
> David
> 
> 
> Dominik Szczerba wrote:
> 
>> Hi,
>>
>> I have a quite complex pipeline with a few actors and filters. When I 
>> clean up at the end I always get a non-zero reference count somewhere 
>> (using C++). How do I robustly know in which order I should Delete my 
>> components?
>>
>> PS. this is particularly annoying in combination matlab-vtk, as matlab 
>> dies on any of such errors.
>>
>> regards,
>> Dominik
>> _______________________________________________
>> This is the private VTK discussion list. Please keep messages 
>> on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 
> 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers

-- 
Dominik Szczerba, Ph.D.
Computer Vision Lab CH-8092 Zurich
http://www.vision.ee.ethz.ch/~domi



More information about the vtkusers mailing list