Running GdPicturePdf.OcrPages doesn't free used memory

Discussions about PDF management.
Post Reply
dgosolo
Posts: 1
Joined: Wed May 31, 2023 8:08 am

Running GdPicturePdf.OcrPages doesn't free used memory

Post by dgosolo » Wed May 31, 2023 8:57 am

When I run OCR on pdf documents containing images of text around 1 GB of memory is used. The memory is not released, even though I dispose the PDF and clear/close it as much as possible.

I attach the project I used to test this. The most important part of code is below:

Code: Select all

      var files = Directory.GetFiles(txtInputFile.Text);
      foreach (var file in files)
      {
        using (var pdf = new GdPicturePDF())
        {
          pdf.LoadFromFile(file);
          if (pdf.OcrPages("*", 0, "eng", txtDictsPath.Text, string.Empty, 300, OCRMode.FavorAccuracy, 30000, true) != GdPictureStatus.OK)
          {
            throw new Exception("Ocr failed");
          }

          pdf.ClearCachedResources();
          pdf.CloseDocument();
          GdPictureDocumentUtilities.ForceGarbageCollection();
        }
      }
The PDF files are to large for forum. They are available here https://drive.google.com/file/d/1nzphj4 ... sp=sharing

Am I doing something wrong? Is it bug in library? Is it intended behaviour?
Attachments
example.zip
(166.9 KiB) Downloaded 1510 times

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest