Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Accessing histogram leaks resources #397
Hey, folks. I've tried using the histogram function for a picture and hit some rough edges. First, simply accessing it leaks resources, which is reproducible with the following program
I've also tried swapping the order of "with" and "for". The issue seems to be that a 'PixelWand' object is initialized with the object and never properly handled at
The other issue is that I can't even iterate over the values of this histogram:
My guess is that the function used to build the dict keys in
Hey, thanks for the research!
Looks like the memory leak is caused by python deleting the ctypes container, and not allowing ImageMagick to deallocate the resources. Should be something closer too...
self.pixels = library.DestroyPixelWands(self.pixels, self.size.value) # <= this is missing del self.size, self.pixels
As far as the
I believe the whole
Sorry, I was indeed trying to fix HistogramDict in a local copy.
I've added the following line to test_histogram in test_image.py and can reproduce the error:
raises 'ValueError: Unrecognized color string "0,1,0"'
It seems that this code predates having Color as hashable objects, so it may make sense to forego the string conversion and use the object itself as key, WDYT?
Spent a little time on this. Checkout branch
Color hashing was apart of the same release as HistogramDict, but I can't speak about the original authors intent & implementation. The whole string conversion is related to the