Welcome Guest Search | Active Topics | Sign In | Register

EO.PDF Memory Leak Options
absoffthewake
Posted: Friday, March 5, 2021 5:04:59 PM
Rank: Member
Groups: Member

Joined: 2/12/2020
Posts: 14
We are having an issue with memory leaks in EO.Pdf. The code we are using is below. It has been happening since EO.PDF 2019 and is still occurring on 2021. We previously had significant issues with .GeneratePageImages = true and we fixed it by disposing the images (code below), but the code still has a leak (albiet smaller) even when this is set to false (or not set).

Using DotMemory, it appears there is a TimerQueueTimer and/or TimerCallback that is preventing HtmlToPDFResult/PdfDocument from being garbage collected. These increment for every iteration of the code below. Objects seem to remain alive for the duration of the program. Are we doing something wrong?

DotMemory Screenshot https://1drv.ms/u/s!AtcL5uaBU494gQABLhQmB5O2g1Dl?e=evOH7U

Code: C#
private const float X_MARGIN = .4f;
private const float Y_MARGIN = .5f;

string customFooterText = "test"
string html;

HtmlToPdfOptions htmlToPdfOptions = new HtmlToPdfOptions();
htmlToPdfOptions.PageSize = new SizeF(8.5f, 11f);
htmlToPdfOptions.OutputArea = new RectangleF(X_MARGIN, Y_MARGIN, 8.5f - (2 * X_MARGIN), 11 - (2 * Y_MARGIN));
htmlToPdfOptions.FooterHtmlFormat = customFooterText;

PdfDocument doc = new PdfDocument();
HtmlToPdfResult result = HtmlToPdf.ConvertHtml(html, doc, htmlToPdfOptions);

if (result != null && result.PageImages != null)
{
     foreach (var image in result.PageImages)
     image.Dispose();
}

//According to the EO support forum, this clears objects from the previous convert call
HtmlToPdf.ConvertHtml(string.Empty, new PdfDocument());
HtmlToPdf.ClearResult();


absoffthewake
Posted: Friday, March 5, 2021 6:29:08 PM
Rank: Member
Groups: Member

Joined: 2/12/2020
Posts: 14
We traced a production system and got some different results. On this machine, it seems like HtmlToPdfOptions is leaking and not HtmlToPdfResult. Kinda strange. DotMemory also shows there is a vague system object holding the reference. Don't know what to think now but something is definitely leaking.

https://1drv.ms/u/s!AtcL5uaBU494gQFxHEw-39bvZz8n?e=40NSiN
eo_support
Posted: Tuesday, March 9, 2021 3:06:33 PM
Rank: Administration
Groups: Administration

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

We are aware of this issue (ClearResult does not clear the internal reference to the result objects immediately). This issue will be corrected in our next build. We will reply here again as soon as the new build is available.

Thanks
absoffthewake
Posted: Tuesday, March 9, 2021 5:55:02 PM
Rank: Member
Groups: Member

Joined: 2/12/2020
Posts: 14
Thank you! We look forward to the new build.
Noel Lawrence
Posted: Thursday, August 12, 2021 11:17:37 AM
Rank: Newbie
Groups: Member

Joined: 8/31/2018
Posts: 1
Hello EO,

Was this fixed within the latest build? If so, what was the build #? Thanks
eo_support
Posted: Thursday, August 12, 2021 11:25:56 AM
Rank: Administration
Groups: Administration

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

Yes. This issue was fixed in build 2021.0.62.

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.