Using Tesseract for OCR gives memory leak on GetUTF8Text method
c++, ios, iphone, ocr, tesseract
Solution
According the documentation I found in baseapi.h.
/**
* The recognized text is returned as a char* which is coded
* as UTF8 and must be freed with the delete [] operator.
*/
char* GetUTF8Text();
So you will need to `delete []` the `utf8text` when you are done with it.
tesseract->Recognize(NULL);
char* utf8Text = tesseract->GetUTF8Text();
... //use utf8Text or copy if necessary
delete [] utf8text;
Problem
I am using tesseract OCR for business card reading. I have a memory leak and I can't resolve it, I don't know how to. In my code... ``` tesseract->Recognize(NULL); char* utf8Text = tesseract->GetUTF8Text(); ``` GetUTF8Text() method gives memory leak. Here is the log in memory leak instruments: ``` tesseract::TessBaseAPI::GetUTF8Text() operator new[](unsigned long) libstdc++.6.dylib operator new(unsigned long) libstdc++.6.dylib malloc libsystem_c.dylib ``` After some memory leaks, app crashes. GetUTF8Text is in baseapi.h file. I think tessearact was written by c++. I don't know c++. Can anyone help? Or anyone has clean tesseract?