|
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();
|
|
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
|
|
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
|
|
Rank: Member Groups: Member
Joined: 2/12/2020 Posts: 14
|
Thank you! We look forward to the new build.
|
|
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
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
Yes. This issue was fixed in build 2021.0.62.
Thanks!
|
|