We have a following lines of code to check the memory usage and dispose in Aspose PDF NET 22.3.0
string[] _pdfFiles = new string[] {
"Data/sample_45_mb.pdf",
"Data/Nikon16mb.pdf",
"Data/24mb.pdf",
"Data/sample_45_mb.pdf",
"Data/Nikon16mb.pdf",
"Data/24mb.pdf",
"Data/sample_45_mb.pdf",
"Data/Nikon16mb.pdf",
"Data/24mb.pdf",
"Data/sample_45_mb.pdf"
};
foreach (var fileName in _pdfFiles)
{
using (var file = File.OpenRead(fileName))
{
using (Document document = new Document(file))
{
using (MemoryStream textStream = new MemoryStream())
{
Aspose.Pdf.Devices.TextDevice textDevice = new Aspose.Pdf.Devices.TextDevice();
Aspose.Pdf.Text.TextExtractionOptions textExtOptions = new
Aspose.Pdf.Text.TextExtractionOptions(Aspose.Pdf.Text.TextExtractionOptions.TextFormattingMode.Raw);
textDevice.ExtractionOptions = textExtOptions;
textDevice.Process(document.Pages[1], textStream);
string extractedText = Encoding.Unicode.GetString(textStream.ToArray());
}
}
}
}
We are observing the the Aspose is not disposing memory even after completion of the execution of above code (foreach loop).
Ex: In Performance profiler we saw the Aspose is still using 200+ MB of memory after this code execution.
Link for the above files
Any suggestions much appreciated.