Welcome Guest Search | Active Topics | Sign In | Register

EO.PDF memory usage and optimisation Options
Andy
Posted: Tuesday, July 8, 2025 10:47:43 AM
Rank: Newbie
Groups: Member

Joined: 7/8/2025
Posts: 2
Hi,
We've been seeing high memory usage from EO.PDF at times which we've been struggling to pin down. We're using HtmlToPdf to convert HTML strings, these can be quite large at up to thousand pages output but no significant image content. We're seeing memory usage of 20GB at times for a 100MB PDF output, the majority being allocated as byte arrays.

We are seeing some growth over time which appears to be related to large object heap fragmentation. Forcing garbage collection does seem to free all memory successfully and we've seen some references to using a separate AppDomain as potential option to manage fragmentation. Is there a general method that works best here?

Regarding peak usage, are the any recommended approaches to reduce and manage memory usage? We've seen some a few posts that suggest setting HtmlToPdfOptions.RetrieveNodeText to false but couldn't find anything around any potential drawbacks.

Thanks!
eo_support
Posted: Tuesday, July 8, 2025 12:13:33 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,388
Hi,

Which version do you use? Our older version could use more memory because Chromium rendering engine tries to "optimize" the rendering process by buffering extra pages, which produces smoother screen scrolling experience but was not needed for PDF rendering. This optimization has been bypassed in our new version which would result in smaller memory footprint. So if you are using an older vesion, try to update to the current version first.

Additionally, when you see 20GB memory usage, do you see it in your process or one of the child processes (by default rundll.exe unless you switches to eowp.exe).

You can safely set RetrieveNodeText to false if you do not need text information in the returned HtmlToPdfResult object. If you use many concurrent conversions, you can also call this method to clear the conversion:

https://www.essentialobjects.com/doc/eo.pdf.htmltopdf.clearresult.html

This does not destroy the HtmlToPdfResult object itself. It merely removes the internal reference to the object so that it is eligible for garbage collection. You can still hold your own reference to that object to avoid it being GCed.

Please let us know if any of the above options improves the situation.

Thanks
Andy
Posted: Tuesday, July 8, 2025 12:44:11 PM
Rank: Newbie
Groups: Member

Joined: 7/8/2025
Posts: 2
Hi,
Thanks for clarifying the purpose of RetrieveNodeText, we'll try setting that to false and see if it improves our memory usage.

We're currently running 25.1.22, we hadn't spotted anything memory related in the change logs but happy to try an upgrade if there has been some relevant changes.

The high memory usage is within our own process which is a Windows service, we are using the eowp process but haven't seen any issues within the child processes. We have recently added the ClearResult method after saving the PDF which helped while the service was idle but didn't affect peak usage while converting.

Thanks.
eo_support
Posted: Wednesday, July 9, 2025 12:06:07 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,388
Hi,

The changes we mentioned in our previous reply is inside the browser engine so it would impact the memory usage of the child process but not your process. Since the high memory usage is in your process, it would not be related to that.

The most likely cause that signficiantly increases the memory consumption in your process would be font data and images. Internally we cache font data so if your PDF file uses large font set extensively then it can increase memory usage. Images can also signficiantly increase memory consumptions --- sometimes even if your HTML file does not use images directly, it can still be rendered as images internally due to certain CSS styles. For example, a CSS drop shadow can be rendered as an image in PDF file. Certain font effects can be rendered as images as well. Chromium browser engine tends to render more contents as images as it evolves when it seeks to "perfect" the output on screen. This could explain why newer version uses more memory.

To precisely pinpoint the root of the problem, we would need a test project to debug it on our end. For example, if you have a test HTML file that produces 100MB PDF file but consumes 10GB memory while doing so, send us the test HTML file and we will debug into it and see if there is any specific HTML elements in your file that triggers the memory consumption. We may not be able to "fix" it but we might be able to tell you how to get around it.

You can find more information on how to send the test project to us here:

https://www.essentialobjects.com/forum/test_project.aspx

Thanks!


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.