Hi,
We are having issues with apparent memory leaks. We are using the Aspose PDF libraries. We have attempted to call FreeMemory on both the Document and Page objects, but upon doing so, our memory usage actually increased. We are utilizing the TextFragmentAbsorber for both exact text matching and iterating the text fragment collection of a region. The code for that is below:
public TextFragment[] CollectTextFragments(Page page)
{
var textFragmentAbsorber = new TextFragmentAbsorber
{
TextSearchOptions =
{
Rectangle = new Rectangle(0, (page.Rect.Height/2), page.Rect.Width, page.Rect.Height),
LimitToPageBounds = true
},
};
page.Accept(textFragmentAbsorber);
var textFragmentCollection = textFragmentAbsorber.TextFragments;
var textFragColl = new TextFragment[textFragmentCollection.Count];
textFragmentCollection.CopyTo(textFragColl, 0);
return textFragColl;
}
public TextFragment[] CollectTextFragments(Document document, string identifier){
var regexString = @"\b" + identifier + @"\b";
var textFragmentAbsorber = new TextFragmentAbsorber(regexString, new TextSearchOptions(true));
document.Pages.Accept(textFragmentAbsorber);
var textFragmentCollection = textFragmentAbsorber.TextFragments;
var textFragColl = new TextFragment[textFragmentCollection.Count];
textFragmentCollection.CopyTo(textFragColl, 0);
document.Pages.FreeMemory();
return textFragColl.ToArray();
}
We are having very inconsistent behavior in how much memory is allocated and the service we have around this process is unable to release the memory at all.
Please let me know if you have any questions as this is drastically affecting scalability. When trying to analyze a 500 page document (~12 MB), the process is allocating multiple GB of memory.
Hi Phil,
Hi Philippe,