How to fix exception Invalid memory access failed loading language in tess4j

114 Views Asked by At

I have a code where I read image text using Tesseract in java 8.

I even changed the Datapath to point within the source folder on eclipse but still getting this exception within that period of running the program.

How do I fix this problem? Should I dispose the BufferedImage if possible how to do that?

1

There are 1 best solutions below

1
nguyenq On

setDatapath should not be in the loop; it needs be called only once after the Tesseract instance is created. I would dispose of the instance and start a new one after so many OCR operations; otherwise, the memory leaks in the native code will eventually crash the JVM.