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

Cannot enlarge memory arrays error after trying to run recognize on a second image #100

Closed
davidworkman9 opened this issue Jan 30, 2017 · 8 comments

Comments

@davidworkman9
Copy link

This works great the first time a user uploads an image, but the second time on the same session, the following error is thrown:

Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 100663296, (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.

Even if I pick the same image twice in a row I get this error.

@ashokkumarjuly
Copy link

@davidworkman9, hi had you got any solution.

@davidworkman9
Copy link
Author

@ashokkumarjuly unfortunately no, I never found a way around this.

@rmadisonhaynie
Copy link

Hello @ashokkumarjuly I am getting the same error for files that are too large. My main issue is this error doesn't get caught in the catch function. Should this be a separate issue?

@davidworkman9 do you mind sharing your work around?

@davidworkman9
Copy link
Author

@rmadisonhaynie sorry if I wasn't clear, I never found a workaround for this. It was only for a pet project that I haven't worked on since I ran into this.

@ryanfb
Copy link

ryanfb commented Dec 28, 2017

I ran into the same issue and found two ways around it.

  1. The hard way: recompile https://github.com/naptha/tesseract-emscripten with -s ALLOW_MEMORY_GROWTH=1 and use the resulting core for the corePath when initializing Tesseract.js (as described here). Unfortunately I wanted to use this on iOS devices and this allowed memory growth beyond what MobileSafari would support, so the resulting core would crash when trying to do recognition on mobile. Which lead me to...
  2. The easy way: download the dist version of worker.js corresponding to your Tesseract.js version, e.g. https://cdn.rawgit.com/naptha/tesseract.js/1.0.10/dist/worker.js. Increase the MIN_MEMORY amount e.g. here: https://github.com/naptha/tesseract.js/blob/master/dist/worker.js#L8928. Use the resulting modified worker.js for the workerPath when initializing Tesseract.js (as described here). You may need to do a few rounds of this to experimentally determine what the minimum amount of memory you can get away with for a particular training file/image/browser is.

@yurymuski
Copy link

@ryanfb could you be more specific how to compile with '-s ALLOW_MEMORY_GROWTH=1' ?
CFLAGS="ALLOW_MEMORY_GROWTH=1" ./configure ?

@ryanfb
Copy link

ryanfb commented Nov 30, 2018

@yurymuski: I added -s ALLOW_MEMORY_GROWTH=1 to https://github.com/naptha/tesseract-emscripten/blob/master/javascript/Makefile on the lines after -s TOTAL_MEMORY=268435456 before calling emmake make node. I also had to change wumbo to src.

@jeromewu
Copy link
Member

ALLOW_MEMORY_GROWTH=1 is now added to the CMakeLists.txt (https://github.com/jeromewu/tesseract/blob/4.1.0-tesseract.js/CMakeLists.txt#L468), hope it helps.

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

No branches or pull requests

6 participants