[Insight-users] Memory Management
Andreas Schuh
andreas.schuh.84 at googlemail.com
Tue Mar 31 17:31:29 EDT 2009
Hi Michael,
yes, a smart pointer variable decreases the reference counter of the
referenced object when it is destroyed, e.g. by leaving the scope it was
declared in. If the reference counter of an object becomes zero, the
object destroys itself.
But be aware of cyclic references. So if object A has a smart pointer
member variable that references to object B and object B has a smart
pointer variable that references to object A, neither of them will ever
be destroyed, unless you force the release of one of them.
--
regards
Andreas
Michael Jackson schrieb:
> _Still_ kinda new to itk and I am trying to track down a memory leak
> in my program. I just want to make sure that if I stick to things like:
>
> MetricType::Pointer metric = MetricType::New(); that when that
> variable goes out of scope that the object will be destroyed?
>
> Thanks for the sanity check.
>
> _________________________________________________________
> Mike Jackson mike.jackson at bluequartz.net
> BlueQuartz Software www.bluequartz.net
> Principal Software Engineer Dayton, Ohio
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
More information about the Insight-users
mailing list