We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Severe Memory Usage by Aspose PDF libraries

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,


Thanks for contacting support.

I have tested the scenario using one of my sample PDF files and I am unable to notice any issue. Can you please share some sample project along with resource file, so that we can test the scenario in our environment. We are sorry for this inconvenience.

Hello

yes, there is an issue. It is the same as
Heavy memory consumption on Document.Find()

Hi Philippe,


Thanks for contacting support.

I have tested the complete scenario using the code snippet which you have shared with my sample file (~26 MB, 1718 Pages) and I was unable to notice the memory leaks or memory consumption issue. I have also checked the thread which link you have shared. Please note that sometimes issue is related to specific input document so as requested earlier please share a sample input document you are facing the issue with. It will really help us in understanding the issue and get back to you accordingly.

We are sorry for the inconvenience.


Best Regards,