Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Fix memory leak in setImage(Bitmap bmp) #154

Merged
merged 1 commit into from
Jun 16, 2016
Merged

Fix memory leak in setImage(Bitmap bmp) #154

merged 1 commit into from
Jun 16, 2016

Conversation

megabytefisher
Copy link
Contributor

Hello, this is my first pull request to an open source project, so please excuse me if I've done anything wrong and I'll fix my mistakes.

I am working on a project, which rapidly uses OCR provided by tess-two, and noticed a memory leak. I narrowed it down and found that, instead of calling setImage(Bitmap), I could create a Pix object myself, call setImage(Pix), and then recycle the Pix object. This fixed the memory leak for me, but I believe this commit will fix the memory leak when using the Bitmap variant of the method. There is no way to recycle the Pix object outside of this call, since it is only used as a temporary local object.

I tested this and it does seem to work, but I am no expert on Tesseract, so please let me know if you see any issues that may arise.

Thanks for your time.

The Pix object was never recycled, causing it to never release image memory.
@rmtheis
Copy link
Owner

rmtheis commented Jun 16, 2016

Yep, good catch. The contribution is appreciated. If you notice anything else that could be improved please don't hesitate to open a pull request or issue.

@rmtheis rmtheis merged commit 5489609 into rmtheis:master Jun 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants