[ITK] [ITK-users] Memory leak in Python wrapped Image GetPixel method?
Paavolainen, Lassi
lassi.paavolainen at jyu.fi
Mon Mar 9 15:59:26 EDT 2015
Hi Matt,
Seems its an issue with local environment. Here is also for the list what I replied to Gaetan:
"This is interesting. I'm using ITK 4.6.1 with swig that comes with it. I now tested with 3.20 that has been built long time ago with swig 1.9 (if I remember correctly). The same thing. So the conclusion is that it must be something local as I'm sure I've done something similar over the years many times.
Next is to try to find out what on my environment causes this."
To add to that, I ran 30 iterations using valgrind. Here is the report:
==8603== HEAP SUMMARY:
==8603== in use at exit: 478,066,856 bytes in 483,719 blocks
==8603== total heap usage: 657,312 allocs, 173,593 frees, 787,087,705 bytes allocated
==8603==
==8603== LEAK SUMMARY:
==8603== definitely lost: 0 bytes in 0 blocks
==8603== indirectly lost: 0 bytes in 0 blocks
==8603== possibly lost: 20,224 bytes in 34 blocks
==8603== still reachable: 478,046,632 bytes in 483,685 blocks
==8603== suppressed: 0 bytes in 0 blocks
So almost 500 MB is in heap but still reachable when the program exits.
Lassi
________________________________________
From: Matt McCormick [matt.mccormick at kitware.com]
Sent: Monday, March 09, 2015 20:22
To: Paavolainen, Lassi
Cc: insight-users at itk.org; Gaëtan Lehmann; Michka Popoff
Subject: Re: [ITK-users] Memory leak in Python wrapped Image GetPixel method?
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
_____________________________________
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 Community
mailing list