Free Support Forum - aspose.com

Exception of type 'System.OutOfMemoryException' was thrown when accessing the Document

The following codes throw the above mentioned exception with a large size PDF file. Would you investigate it?
Aspose.Pdf 18.8 / .NET Core 2.1

[Failure 1] TextFragmentAbsorber

Document doc = new Document(inputfilename);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(".+");
textFragmentAbsorber.TextSearchOptions = new TextSearchOptions(true);
textFragmentAbsorber.TextReplaceOptions.ReplaceAdjustmentAction = TextReplaceOptions.ReplaceAdjustment.WholeWordsHyphenation;
doc.Pages.Accept(textFragmentAbsorber);

[Failure 2] ParagraphAbsorber

Document doc = new Document(inputfilename);
ParagraphAbsorber absorber = new ParagraphAbsorber();
absorber.Visit(doc);

I’m afraid but the input file is too large to attach to this ticket, so please visit here https://docs.microsoft.com/en-US/aspnet/core/fundamentals/choose-aspnet-framework?view=aspnetcore-2.1 and hit “Download PDF” link bottom left to get it. It weighs over 30MB.

Thank you for your cooperation.

@KDSSHO

Thanks for contacting support.

We have tested the scenario in our environment and noticed that the program execution caused system hung up and we had to force stop the execution. However, we did not manage to get proper exception in our environment. Would you please share Exception Message and Stack Trace in text format with us. We will log an issue with all necessary details so that it can be investigated accordingly. It would also be appreciated if you can please share your environment details (e.g. OS Version, Installed Memory, Application Type, etc.).

I added the following catch statement and got the result below.

try
{
    //      doc.Pages.Accept(textFragmentAbsorber); // In Failure 1 code snippet
    //      absorber.Visit(doc); // In Failure 2 code snippet
}
catch (Exception e)
{
    Console.Error.WriteLine("[message]\r\n " + e.Message);
    Console.Error.WriteLine("[source]\r\n " + e.Source);
    Console.Error.WriteLine("[stacktrace]\r\n" + e.StackTrace);
    return ;
}

[Failure 1 exception result]


[message]
 Exception of type 'System.OutOfMemoryException' was thrown.
[source]
 Aspose.Pdf
[stacktrace]
   at Aspose.Pdf.Color.FromRgb(Double r, Double g, Double b)
   at Aspose.Pdf.Text.TextState.(??? )
   at Aspose.Pdf.Text.TextState.(??? )
   at Aspose.Pdf.Text.TextState.(TextState , ??? )
   at Aspose.Pdf.Text.TextState.(??? )
   at Aspose.Pdf.Text.TextState..ctor(TextSegment )
   at Aspose.Pdf.Text.TextSegment.(??? , Int32 , Int32 , TextEditOptions)
   at Aspose.Pdf.Text.TextFragmentAbsorber.??? , [] )
   at Aspose.Pdf.Text.TextFragmentAbsorber.Visit(Page page)
   at Aspose.Pdf.PageCollection.Accept(TextFragmentAbsorber visitor)
   at <*My code snippet>

[Failure 2 exception result]

[message]
 Exception of type 'System.OutOfMemoryException' was thrown.
[source]
 Aspose.Pdf
[stacktrace]
   at Aspose.Pdf.Matrix.Transform(Rectangle rect)
   at Aspose.Pdf.Text.MarkupSection.(List`1 )
   at Aspose.Pdf.Text.PageMarkup.()
   at Aspose.Pdf.Text.ParagraphAbsorber.Visit(Page page)
   at Aspose.Pdf.Text.ParagraphAbsorber.Visit(Document doc)
   at <*My code snippet>

OS Version: Windows 10 Pro 64bit ver 1803 build 17134.228

Installed Memory: 16GB
(11.4GB is available before I start this test, then it goes down to 9.6GB when the exception catched.)

Application Type: I’m not sure what to answer to this question. My codes are for .NET Core Self-contained deployment .exe executable for Windows.

@KDSSHO

Thanks for sharing requested details.

We have logged a performance issue as PDFNET-45289 in our issue tracking system. We will further investigate it in details and keep you informed with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hi.

Any update here? If not, I’ll just wait.

@KDSSHO

Thanks for your inquiry.

I regret to share that earlier logged issue is not yet resolved due to other pending issues in the queue. As soon as we have some updates regarding resolution progress, we will surely let you know. Please be patient and spare us little time.

We are sorry for the inconvenience.

Thank you. I understand the status.