[Insight-users] SmartPointer, reference count, destructors and main exit

Julien Michel julien.michel at c-s.fr
Tue Oct 6 09:16:04 EDT 2009


Luis Ibanez a écrit :

> Hi Julien,
> 
> 
> Thanks for the confirmation.
> 
> 
> We have put together a minimal case of what you described
> and confirmed that a memory  leak happens in this case.
> 
> 
> Attached is the SmartPointer1.cxx file, along with its
> Here is the CMakeLists.txt file, that replicate the problem.
> 
> Since you are creating a loop of connections,
> The solution is to use a WeakPointer in one of
>  the connections.
> 
> This solution is illustrated in SmartPointer2.cxx,
> also attached.

Thank you Luis. I did also put a minimal case reflecting my (weak) 
design. The only difference with yours is that the loop of connection is 
less obvious, because it happens through pointers to base classes, 
because we tried to let some classes know just what they need to know 
about some others. But I understand the problem now and will have a 
close look to the design and in last resort use the WeakPointer. Thank 
you very much for your help,

Best regards,

Julien
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Julien MICHEL - Ingénieur d'études - Traitement d'images
CS Systèmes d'Information - Division ESPACE
Département Information Géographique & Image
Téléphone : +33 561 17 64 27
Email : julien.michel at c-s.fr

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



More information about the Insight-users mailing list