Running GdPicturePdf.OcrPages doesn't free used memory
Posted: 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:
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?
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();
}
}
Am I doing something wrong? Is it bug in library? Is it intended behaviour?