Welcome Guest Search | Active Topics | Sign In | Register

Out of Memory Exception Options
Posted: Tuesday, June 21, 2022 12:56:08 AM
Rank: Newbie
Groups: Member

Joined: 6/21/2022
Posts: 1
I'm getting an out of memory exception when using ConvertHTML. The strings I'm feeding is just a small file (108KB or less than 1MB). To diagnose further, I tried feeding a simple html (like below) to test but the results did not change.

The version we have is v2022.1.42.0.

I've got the logs and image but is unsure how to attach it here.

The code I've used is:
Dim tempPathPdf = "c:\Temp\Hello.pdf"
HtmlToPdf.Options.PageSize = EO.Pdf.PdfPageSizes.A4
HtmlToPdf.Options.OutputArea = New RectangleF(0, 0, PdfPageSizes.A4.Width, PdfPageSizes.A4.Height)
HtmlToPdf.ConvertHtml("<br>Alex test", tempPathPdf)

The message for the exception is "Exception of type 'System.OutOfMemoryException' was thrown."
and the stacktrace is
" at EO.Internal.mhtv.nwbe(String& nsb, Int32& nsc)" & vbCrLf & " at EO.Internal.mhts.qmkx.wmhe(mhtv nrn)" & vbCrLf & " at EO.Internal.mhts.prem(Boolean& nmn, mhtv[] nmo, String nmp, String nmq)" & vbCrLf & " at EO.Internal.mhts.namb(mhtv[] nmk, String nml, String nmm)" & vbCrLf & " at EO.Internal.mhtt.namb(String nrw, String nrx)" & vbCrLf & " at EO.Internal.vmim.wumo()" & vbCrLf & " at EO.Internal.vmim.wnjy.shjw()" & vbCrLf & " at EO.Internal.mhpf.kwbe(Action lup)" & vbCrLf & " at EO.Internal.vmim.uarp(WindowsIdentity fs)" & vbCrLf & " at EO.WebEngine.Engine.Start(WindowsIdentity user)" & vbCrLf & " at EO.WebEngine.Engine.Start()" & vbCrLf & " at EO.Internal.yguf.bspw()" & vbCrLf & " at EO.Internal.ygug.bspw(yguf& bra)" & vbCrLf & " at EO.Internal.yguh.bspw(vmih bre, yguf& brf)" & vbCrLf & " at EO.Internal.yguk.mobn()" & vbCrLf & " at EO.Internal.yguk..ctor(vmih brj, HtmlToPdfOptions brk)" & vbCrLf & " at EO.Pdf.HtmlToPdfSession.hjdk(HtmlToPdfOptions yt)" & vbCrLf & " at EO.Pdf.HtmlToPdfSession..ctor(HtmlToPdfOptions yq, HtmlToPdfSession yr, ResourceHandler ys)" & vbCrLf & " at EO.Pdf.HtmlToPdfSession.Create(HtmlToPdfOptions options, ResourceHandler resourceHandler)" & vbCrLf & " at EO.Pdf.HtmlToPdf.nxmj.hpwd()" & vbCrLf & " at EO.Internal.yguh.socp[a](mhod`1 bri)" & vbCrLf & " at EO.Pdf.HtmlToPdf.ConvertHtml(String html, PdfDocument doc, HtmlToPdfOptions options)" & vbCrLf & " at EO.Pdf.HtmlToPdf.ConvertHtml(String html, String pdfFileName, HtmlToPdfOptions options)" & vbCrLf & " at EO.Pdf.HtmlToPdf.ConvertHtml(String html, String pdfFileName)" & vbCrLf & "
Posted: Tuesday, June 21, 2022 10:22:07 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 23,374

This might be an issue on our end. Can you send us the HTML file in question so that we can debug it here? See here for more details on how to send test files to us:


Posted: Wednesday, June 22, 2022 3:25:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 23,374

We looked into the logs you sent to us. The problem occurred when you call ConvertHtml for the first time and the code tries to initialize the browser engine, which needs to make a one time allocation close to 90M in memory. Because it failed while initliaziaing browser engine, it has not got to the point to load your HTML contents yet, so the issue has nothing to do with your input HTML.

On a 64 bit system it is rare to fail an allocation for 90M unless you have something specifically limits the amount of memory your process can use. If that's the case, you would need to find out exactly who is limiting your process memory usage. Any program that has administrator privilege can call this Windows API to limit how much memory your application can use:


You can find an example of how this method is used here (look for SetBasicLimits method):


Because any program that has administrator privilege can call this API to put a limit on your program, there is no way for us to tell you exactly who set the limit for you. You would have to find that out yourself.

If you have no way to remove the limit, then you can try to initailize the browser engine early by calling this code:

Code: C#
HtmlToPdf.ConvertHtml(string.Empty, new PdfDocument());

For example, if you initialize the browser engine immediately after your application starts, you might have a better chance to get your 90M than if you try to get the same 90M after much other code has already run and allocated some memory and and have fragmented your memory space. However the idea solution should be for you to find out why there is a limit on your process and have that limit increased/removed.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.