[ITK-users] Memory leak in Python wrapped Image GetPixel method?

Matt McCormick matt.mccormick at kitware.com
Mon Mar 9 14:22:24 EDT 2015


Hi Lassi,

Thanks for investigating and reporting the issue!

I have created an issue in the Issue Tracker to keep track of it:

  https://issues.itk.org/jira/browse/ITK-3352

Matt

On Mon, Mar 9, 2015 at 6:11 AM, Paavolainen, Lassi
<lassi.paavolainen at jyu.fi> wrote:
> Hi,
>
> I noticed that GetPixel method in itk.Image object eats memory in Python wrapped code. I think I've seen some Python wrapping memory issues years ago but nothing as simple as this. Here is a simple test script:
> import sys
> import itk
> reader = itk.ImageFileReader.IUC2.New()
> reader.SetFileName(sys.argv[1])
> reader.Update()
> img = reader.GetOutput()
> size = img.GetLargestPossibleRegion().GetSize()
> for i in range(100):
>         for x in range(size[0]):
>                 for y in range(size[1]):
>                         value = img.GetPixel((x,y))
>         print "Done with iteration %d"%(i+1)
>
> When I run it with 1 MB image, it end up taking 1.5 GB of memory. After spending lots of time on debugging a bigger bunch of code I realized that the GetPixel method was to blame. Can anyone reproduce it? I'm using ITK 4.6.1
>
> Cheers,
> Lassi
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> 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://public.kitware.com/mailman/listinfo/insight-users


More information about the Insight-users mailing list