Hello,
I have a peice of code that repeatidly draws new images (draw_image)
and then compares the images drawn against an origional image
(image_cost).
If I remove the PIL functions in these functions the rest of the code
runs fine, and does not exhibit a memory leak, however when using PIL
repeatidally in these functions I soon run out of memory. It's as if
PIL is caching the images in memory or not cleaning up memory ... I've
tried png, gif formats all eventually give a malloc of the period of
the code run.
error
Python(2046) malloc: *** mmap(size=16777216) failed (error code=12)
def draw_image(popmember,path,img_tick,poly_vector_len):
img=Image.new('RGB',(300,300),(0,0,0))
d = aggdraw.Draw(img)
for strand in range(len(popmember)):
vector = split_strand(popmember[strand],"vec",poly_vector_len)
rgb = split_strand(popmember[strand],"rgb",poly_vector_len)
alpha =
split_strand(popmember[strand],"alpha",poly_vector_len)
b = aggdraw.Brush(tuple(rgb),alpha[0])
d.polygon(vector,b)
d.flush()
img.save(path + str(img_tick) + '.jpg','PNG')
def image_cost(path,image2,img_tick):
h1 = Image.open(path+image2).histogram()
h2 = Image.open(path+str(img_tick)+'.png').histogram()
rms = math.sqrt(reduce(operator.add,map(lambda a,b: (a-b)**2, h1,
h2))/len(h1))
return rms
_______________________________________________
Image-SIG maillist - Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig