Welcome to the WPF feedback portal. We’re happy you’re here! If you have feedback on how to improve the WPF, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
Hello,
we are developing in Visual Studio 2021 a VSTO addin for MS outlook, using c#, WPF and .net framework 4.8.
We are using 'Syncfusion.Pdf.Winforms', version 2.0.2.38 for extracting data from a pdf files and to split into smaller pdf files.
At some point we need to extract informations from a somewhat large pdf (231 pages, of which half are blank). For extracting informations we cycle through the pages of PdfLoadedDocument and on each page we use 'ExtractText' method. Heap memory usage grows to more than 2 GBytes even if it seems to us that we make all the calls to close and dispose the objects used.
Here is some code:
public async Task
{
Shared.ReturnValues.F24Reader returnValue = new Shared.ReturnValues.F24Reader();
try
{
TextLines lineCollection = new TextLines();
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(FilePath);
loadedDocument.EnableMemoryOptimization = true;
using (loadedDocument)
{
for (int i = 0; i < loadedDocument.Pages.Count; i++)
{
Syncfusion.Pdf.PdfPageBase currentPage = loadedDocument.Pages[i];
lineCollection = new TextLines();
string extractedText;
await Task.Run(() =>
{
extractedText = currentPage.ExtractText(out lineCollection);
});
//here is code for extracting information from the linecollection
// --------------------
extractedText = null;
lineCollection = null;
}
}
}
catch (Exception _ex)
{
returnValue.Errors.Add(_ex);
}
return returnValue;
}

extractedText = currentPage.ExtractText(out lineCollection);
It happens also if the call is made without using Task.Run().
Even after the program exits this method the memory is not released and around 2,2 GBytes of RAM are used by outlook.
Probably I'm missing something but I can't find, it seems like a memory leak to me, could you please check?
Thank you,
Andrea