mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-03 00:49:01 +08:00
Merge pull request #912 from stweil/leak
main: Fix two memory leaks and fix order of destructor calls
This commit is contained in:
commit
4e93259a80
@ -27,6 +27,7 @@
|
||||
#include "allheaders.h"
|
||||
#include "baseapi.h"
|
||||
#include "basedir.h"
|
||||
#include "dict.h"
|
||||
#include "openclwrapper.h"
|
||||
#include "osdetect.h"
|
||||
#include "renderer.h"
|
||||
@ -424,7 +425,14 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
PERF_COUNT_START("Tesseract:main")
|
||||
tesseract::TessBaseAPI api;
|
||||
|
||||
// Call GlobalDawgCache here to create the global DawgCache object before
|
||||
// the TessBaseAPI object. This fixes the order of destructor calls:
|
||||
// first TessBaseAPI must be destructed, DawgCache must be the last object.
|
||||
tesseract::Dict::GlobalDawgCache();
|
||||
|
||||
// Avoid memory leak caused by auto variable when exit() is called.
|
||||
static tesseract::TessBaseAPI api;
|
||||
|
||||
api.SetOutputName(outputbase);
|
||||
|
||||
@ -493,7 +501,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<tesseract::TessResultRenderer> renderers;
|
||||
// Avoid memory leak caused by auto variable when exit() is called.
|
||||
static tesseract::PointerVector<tesseract::TessResultRenderer> renderers;
|
||||
|
||||
if (in_training_mode) {
|
||||
renderers.push_back(NULL);
|
||||
|
Loading…
Reference in New Issue
Block a user