[Insight-users] itk.PyBuffer memory leak

Gaëtan Lehmann gaetan.lehmann at jouy.inra.fr
Mon May 11 14:14:30 EDT 2009


Hi Rick,

GetImageFromArray() returns a smart pointer to an image, so the image  
should be deallocated once the python object is destroyed.
Perhaps the problem is there: the garbage collection my not run fast  
enough.

The right way to go may be to implement PyBuffer as a filter which  
reuse the output image, as all the filters in itk.

For the Delete() method: you shouldn't use it in python (and I can't  
see any case for use it but the internal memory management in c++). In  
the latest version of wrapitk (the one hosted at googlecode), Delete()  
and the other methods related to smart pointers are hidden.

Regards,

Gaëtan



Le 11 mai 09 à 05:43, Rick Giuly a écrit :

>
> Hello All,
>
> It seems that converter.GetImageFromArray(inputNumpyVolume)  
> allocates memory in some way and never releases it. When I tried  
> using Delete() the program actually crashed silently after one  
> iteration.
>
> Test code is below. (I'm running this on ubuntu, and the itk package  
> is from Paul Novo's site.)
>
> Is there some way to release memory?
>
>
>
> import itk
> import numpy
>
> for i in range(10000):
>
>    print i
>
>    ImageType = itk.Image[itk.F, 3]
>    converter = itk.PyBuffer[ImageType]
>
>    inputNumpyVolume = numpy.ones((100, 100, 200))
>    inputVolume = converter.GetImageFromArray(inputNumpyVolume)
>    #inputVolume.Delete()
>
>
>
> ----------
> Thanks,
> --Rick
> _____________________________________
> 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

-- 
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
http://voxel.jouy.inra.fr  http://www.mandriva.org
http://www.itk.org  http://www.clavier-dvorak.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: Ceci est une signature ?lectronique PGP
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090511/0facb1a4/attachment-0001.pgp>


More information about the Insight-users mailing list