diff --git a/api/tesseractmain.cpp b/api/tesseractmain.cpp index a1ca145a..3f6b3651 100644 --- a/api/tesseractmain.cpp +++ b/api/tesseractmain.cpp @@ -421,7 +421,9 @@ int main(int argc, char** argv) { } PERF_COUNT_START("Tesseract:main") - tesseract::TessBaseAPI api; + + // Avoid memory leak caused by auto variable when exit() is called. + static tesseract::TessBaseAPI api; api.SetOutputName(outputbase); @@ -490,7 +492,8 @@ int main(int argc, char** argv) { (api.GetBoolVariable("tessedit_resegment_from_boxes", &b) && b) || (api.GetBoolVariable("tessedit_make_boxes_from_boxes", &b) && b); - tesseract::PointerVector renderers; + // Avoid memory leak caused by auto variable when exit() is called. + static tesseract::PointerVector renderers; if (in_training_mode) { renderers.push_back(NULL);