Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak in BinarizeSauvolaTiled and BinarizeSauvola #218

Closed
jli416 opened this issue Oct 24, 2015 · 2 comments
Closed

Memory leak in BinarizeSauvolaTiled and BinarizeSauvola #218

jli416 opened this issue Oct 24, 2015 · 2 comments
Labels

Comments

@jli416
Copy link

jli416 commented Oct 24, 2015

If I run the Pix.BinarizeSauvola or Pix.BinarizeSauvolaTiled functions, they will leak memory and handles. BinarizeOtsuAdaptiveThreshold doesn't cause a problem.

I isolated everything by just passing an 8-bit grayscale image into a large loop in the code below. This leaks about 10MB / iteration (8.5"x11" 300dpi source image) until it crashes because it can't allocate any more memory or resource handles. If I make the loop shorter so that the function ends and the using's dispose, the memory still stays leaked.

Any suggestions?

var converter = new BitmapToPixConverter();
using (Pix pix = converter.Convert(bmp))
{
// Convert RGB to grayscale
using (Pix grayPix = pix.Depth == 32 ? pix.ConvertRGBToGray() : pix.Clone())
{
for (int i2 = 0; i2 < 300; i2++)
{
// Binarize
using (Pix binaryPix = grayPix.BinarizeSauvolaTiled(50, 0.35f, 8, 8))
//using (Pix binaryPix = grayPix.BinarizeOtsuAdaptiveThreshold(50, 50, 5, 5, 0.1f))
{
}
}
}
}

@charlesw charlesw added the bug label Oct 25, 2015
@charlesw
Copy link
Owner

Confirmed, I'll look into it.

charlesw added a commit that referenced this issue Oct 25, 2015
…rizeSauvola, and Pix.BinarizeSauvolaTiled

The Pix methods where using pixaDestroy instead of pixDestroy to delete intermediate Pix structures created b the Binarize* implementation.
@charlesw
Copy link
Owner

Fixed and issued a new release on nuget (2.4.1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants