Issue 713 in tesseract-ocr: Tesseract doesn't release all allocated memory

948 views
Skip to first unread message

tesser...@googlecode.com

unread,
May 27, 2012, 12:15:38 PM5/27/12
to tesserac...@googlegroups.com
Status: New
Owner: ----

New issue 713 by vogel.fr...@gmail.com: Tesseract doesn't release all
allocated memory
http://code.google.com/p/tesseract-ocr/issues/detail?id=713

What steps will reproduce the problem?
1.tess->Init(tessDataPath, languageCode, OEM_TESSERACT_ONLY);
2.tess->~TessBaseAPI();

What is the expected output? What do you see instead?
If you initialize Tesseract 3.02 f.e. with jap.traineddata(3.02 30MB), it
will use about 55MB.
After calling the Destructure is just frees around 25MB, the remaining 30MB
are leaked.

Iam running Tesseract on Mac OSX Lion and iOS 5.

tesser...@googlecode.com

unread,
Aug 3, 2012, 4:22:20 PM8/3/12
to tesserac...@googlegroups.com

Comment #1 on issue 713 by zde...@gmail.com: Tesseract doesn't release all
allocated memory
http://code.google.com/p/tesseract-ocr/issues/detail?id=713

Did you try to call End()[1]?

[1]
http://code.google.com/p/tesseract-ocr/source/browse/trunk/api/baseapi.h#573

tesser...@googlecode.com

unread,
Aug 3, 2012, 4:31:16 PM8/3/12
to tesserac...@googlegroups.com

Comment #2 on issue 713 by vogel.fr...@gmail.com: Tesseract doesn't release
Yes I did, same result.

~TessBaseAPI() is calling End();


tesser...@googlecode.com

unread,
Nov 6, 2012, 3:58:37 PM11/6/12
to tesserac...@googlegroups.com

Comment #3 on issue 713 by zde...@gmail.com: Tesseract doesn't release all
allocated memory
http://code.google.com/p/tesseract-ocr/issues/detail?id=713

Just to be sure: after 'tess->~TessBaseAPI()' did you delete tess?

tesser...@googlecode.com

unread,
Nov 6, 2012, 7:12:34 PM11/6/12
to tesserac...@googlegroups.com

Comment #4 on issue 713 by vogel.fr...@gmail.com: Tesseract doesn't release
Yes I did. Iam calling:
~TessBaseAPI()
delete tess;

The leak still remains.

tesser...@googlecode.com

unread,
Nov 7, 2012, 5:19:02 PM11/7/12
to tesserac...@googlegroups.com

Comment #5 on issue 713 by zde...@gmail.com: Tesseract doesn't release all
allocated memory
http://code.google.com/p/tesseract-ocr/issues/detail?id=713

Then it is question how do you identify memory leak. There was discussion
regarding report from microsoft debugger[1]. But I do not think you are
referring to that.

I tried to do simple test code (in attachment) on Linux and I test it with
valgrind ('valgrind --leak-check=full ./test_memory_leak') and it do not
report any memory leak (it report memory leak if I comment "delete api").

[1] http://code.google.com/p/tesseract-ocr/issues/detail?id=457

Attachments:
test_memory_leak.cpp 781 bytes

tesser...@googlecode.com

unread,
Nov 9, 2012, 3:48:42 AM11/9/12
to tesserac...@googlegroups.com

Comment #6 on issue 713 by vogel.fr...@gmail.com: Tesseract doesn't release
I run your code on my system and led valgrind check it for leaks. The
results are attached.
My system is OSX 10.8. I ran valgrind with tesseract in rev. 726(version i
used in the first post) + leptonica 1.68 and the current one rev. 806 +
leptonica 1.69, all was compiled with LLMV 4.1
Valgrind finds in both runs some leaks. But none with total sum of about
30MB.

To check for memory leaks I used the mach kernel api to give me the
resident_size of the current task.
I will have a further look into this the next days with other memory/leak
monitoring tools.

Attachments:
rev726_chi_tra_LLVM41.txt 33.8 KB
rev806_chi_tra_LLVM41.txt 35.0 KB

tesser...@googlecode.com

unread,
Feb 4, 2013, 5:08:06 PM2/4/13
to tesserac...@googlegroups.com

Comment #7 on issue 713 by zde...@gmail.com: Tesseract doesn't release all
allocated memory
http://code.google.com/p/tesseract-ocr/issues/detail?id=713

Hello, have you been able to make your tests?
Is there is still issue regarding memory leak or can I close this issue
(IMO lost 11,316 bytes is not a issue)?

tesser...@googlecode.com

unread,
Feb 7, 2013, 10:46:24 PM2/7/13
to tesserac...@googlegroups.com

Comment #8 on issue 713 by vogel.fr...@gmail.com: Tesseract doesn't release
Hi,
you are right 11.316byte are no issue and other memory leak detection tools
I used are also not finding any real leaks.
Iam using the api of the mach-kernel to mesure the used memory of the
application and this memory is growing over time. I measured the following.

Memory before Initializing:7.10MB
Memory after Initializing:74.82MB
Tesseract Initialized!
Memory after Recognition:76.64MB
Memory after Recognition:76.79MB
Memory after Dealloc:49.83MB
Press Button to continue.

Memory after Initializing:76.72MB
Tesseract Initialized!
Memory after Recognition:76.85MB
Memory after Recognition:76.86MB
Memory after Dealloc:58.86MB
#Code for this is attached.

The more i init and dealloc tesseract the more memory is needed. After
dealIoc I was expecting to have a memory usage of around 7MB, but thats not
the case. Either its there is a complicated memory leak in tesseract which
gets not detected by the tools or the Mach Kernel is doing something i dont
understand.

Attachments:
main.mm 2.9 KB

tesser...@googlecode.com

unread,
Feb 11, 2013, 11:40:46 AM2/11/13
to tesserac...@googlegroups.com

Comment #9 on issue 713 by zde...@gmail.com: Tesseract doesn't release all
allocated memory
http://code.google.com/p/tesseract-ocr/issues/detail?id=713

I am afraid that there is need for somebody who is familiar with Mach
kernel. Maybe you can try to post this issue on some Mac specific forum...

tesser...@googlecode.com

unread,
Feb 12, 2013, 1:36:22 AM2/12/13
to tesserac...@googlegroups.com

Comment #10 on issue 713 by vogel.fr...@gmail.com: Tesseract doesn't
Ok thanks.
The point is just, i get a memory warning in iOS/OSX after a while of
repeatingly init and deallocating tesseract, which correspond to my memory
measuring.
Anyway i will try to look further into this in a other mac forum.

tesser...@googlecode.com

unread,
May 23, 2013, 11:28:24 AM5/23/13
to tesserac...@googlegroups.com

Comment #11 on issue 713 by uesh...@gmail.com: Tesseract doesn't release
Same problem here. Any solution?

Kind regards

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

tesser...@googlecode.com

unread,
Jul 15, 2013, 8:54:27 AM7/15/13
to tesserac...@googlegroups.com

Comment #12 on issue 713 by macmoons...@googlemail.com: Tesseract doesn't
I have the same problem, too. It seems it comes from the entries of dawgs_
of class SquishedDawg in class Dict.

tesser...@googlecode.com

unread,
Jul 25, 2013, 11:36:52 AM7/25/13
to tesserac...@googlegroups.com

Comment #13 on issue 713 by zde...@gmail.com: Tesseract doesn't release all
allocated memory
http://code.google.com/p/tesseract-ocr/issues/detail?id=713

If you think this is caused by dictionaries, you can turn off
dictionaries[1] or you can recreate language file without dictionaries

[1] http://www.sk-spell.sk.cx/tesseract-ocr-parameters-in-302-version

tesser...@googlecode.com

unread,
Jan 9, 2014, 5:55:48 PM1/9/14
to tesserac...@googlegroups.com
Updates:
Status: WorksForMe

Comment #14 on issue 713 by theraysm...@gmail.com: Tesseract doesn't
Some comments:
Most OS do not report accurate current memory used when you look at
resident set size, as free does not give the memory back to the OS. (It
makes no sense to do so.)

Some of the dawgs are held statically to minimize the time consumed by
deleting and re-creating apis, and memory consumed running them in parallel
from multiple threads. This isn't a real leak, and memory actually used
will not grow over time as a result.

As above, resident set size for most OSs will stay at the peak usage, so it
is hard to see real leaks without using a tool like valgrind.
Reply all
Reply to author
Forward
0 new messages