[ITK] [ITK-users] Memory leak in Python wrapped Image GetPixel method?
Paavolainen, Lassi
lassi.paavolainen at jyu.fi
Mon Mar 9 06:11:55 EDT 2015
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 Community
mailing list