Skip to content

Commit

Permalink
Fix order of destructor calls for DawgCache and TessBaseAPI
Browse files Browse the repository at this point in the history
TessBaseAPI must release its cache use before DawgCache is destroyed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed May 13, 2017
1 parent f37f858 commit 7814259
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/tesseractmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 7814259

Please sign in to comment.