Fix order of destructor calls for DawgCache and TessBaseAPI

TessBaseAPI must release its cache use before DawgCache is destroyed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2017-05-13 11:34:40 +02:00
parent f37f858c99
commit 78142593d2

View File

@ -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"
@ -425,6 +426,11 @@ int main(int argc, char** argv) {
PERF_COUNT_START("Tesseract:main")
// 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;