Code Monkey home page Code Monkey logo

Comments (5)

kevincon avatar kevincon commented on July 25, 2024

I was able to confirm this using the Instruments tool in Xcode. The following "pix_malloc" function seems to allocate 32KB every time "setImage" is called on the Tesseract object:

screen shot 2014-11-12 at 1 59 28 am

from tesseract-ocr-ios.

kevincon avatar kevincon commented on July 25, 2024

It's late so I might be wrong about this, but it looks like the imageThresholder->GetPixRect() call at https://github.com/gali8/Tesseract-OCR-iOS/blob/master/TesseractOCR%2FTesseract.mm#L218 should destroy the Pix result once it's done with it, according to the documentation here: http://fossies.org/dox/tesseract-ocr-3.02.02/classtesseract_1_1ImageThresholder.html#a0b855cc35144b84f150bf39d5342d7f1

In the next day or so I'll try saving a reference to the result of GetPixRect() (possibly in the existing, seemingly unused _pixels member field) and calling the Leptonica function pixDestroy() (https://tpgit.github.io/Leptonica/pix1_8c.html#a11c3800e3ec598556b1f4779a2079bbd) on any pixels that should be thrown away (e.g. between successive calls to setImage()). Or feel free to take a crack at it if you feel up to it.

from tesseract-ocr-ios.

kevincon avatar kevincon commented on July 25, 2024

I believe I've fixed the memory leak. I've added these commits to my existing pull request, but I don't know how active this repo's maintainers are, so in the meantime you can use my fork here: https://github.com/kevincon/Tesseract-OCR-iOS

If you're using CocoaPods, you can add this line to your Podfile to switch to using my fork:

pod 'TesseractOCRiOS', :git => 'https://github.com/kevincon/Tesseract-OCR-iOS.git', :branch => 'master'

from tesseract-ocr-ios.

gali8 avatar gali8 commented on July 25, 2024

Thanks Kevin!
All merged.

from tesseract-ocr-ios.

beamPacer avatar beamPacer commented on July 25, 2024

Thanks kevincon! This is tremendously helpful.

from tesseract-ocr-ios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.