Rank: Newbie Groups: Member
Joined: 6/20/2017 Posts: 2
|
Hello, I am using EO.Pdf.Acm to create a table on the server-side from a list of objects retrieved from our database. I have been testing with about 20,000 objects from the db and I am seeing that when AcmRender.Render(table) is called, my memory usage spikes from ~400MB to ~4GB and does not return to normal levels. In fact, if I call this method again, it spikes from ~4GB to ~6GB and then returns to ~4GB each time the method is called. I potentially have many more objects that will be rendered in production and this is already worrisome. Have we seen this issue on AcmRender before? Is there possibly some method that I am not seeing that needs to be called after the Render() (something akin to HtmlToPdf.ClearResult())?
Code: C#
public Stream ExportAsPdf<T>(IList<T> list)
{
Runtime.AddLicense(Constants.EOLicense);
Type itemType = typeof(T);
int index = 0;
var props = itemType.GetProperties();
PdfDocument doc = new PdfDocument();
// Page layout for landscape. Padding for (L, T, R, B)
AcmPageLayout pageLayout = new AcmPageLayout(
new SizeF(11f, 8.5f), new AcmPadding(0.25f, 0.6f, 0.25f, 0.6f));
AcmRender render = new AcmRender(doc, pageLayout);
render.AfterRenderPage += new AcmPageEventHandler(AfterRenderPage);
// Create table
float[] colWidth = new float[10] { 0.75f, 1, 1, 1, 1, 1, 1, 1, 1, -1f };
AcmTable table = new AcmTable(colWidth);
// Add table header row
AcmTableRow row = new AcmTableRow();
FormatHeaderRow(row);
table.Rows.Add(row);
foreach (var prop in props)
{
AcmTableCell cell = new AcmTableCell(
FormatHeaderRow(new AcmText(prop.Name.ToString().ToUpper())));
row.Cells.Add(cell);
}
// Add data rows
foreach (var item in list)
{
index++;
row = new AcmTableRow();
table.Rows.Add(row);
FormatDataRow(row, index);
foreach (var prop in props)
{
var value = prop.GetValue(item);
var cellA = new AcmTableCell(FormatDataRow(new AcmText(
value != null ? value.ToString() : ""), index));
row.Cells.Add(cellA);
}
}
// *** This is where the memory spike is occurring ***
render.Render(table);
// Add doc to stream
Stream outStream = new MemoryStream();
doc.Save(outStream);
outStream.Position = 0;
return outStream;
}
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,225
|
Hi, AcmRender object does maintain the layout data, so if for some reason that object is not being garbage collected, then you will see this problem. You can use a memory profiler to see which object still keeps a reference to the AcmRender object. My guess is you have some outside object keeps the reference to the AcmRender object through your AfterRenderPage handler. If you can not find out the root cause, please try to isolate the problem into a small test app and send the test app to us. See here for more details: https://www.essentialobjects.com/forum/test_project.aspxOnce we have the test app we will be happy to investigate further. Thanks!
|
Rank: Newbie Groups: Member
Joined: 6/20/2017 Posts: 2
|
Hello,
I sent off a test project on 7/28. Just wondering if anyone has had time to look at it yet.
Thanks.
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,225
|
Hi, We have replied your email on 7/31. So you may want to check your spam folder to see if somehow our reply got caught up there. It has also come to our attention that there are multiple developers in your organization using our product but in fact you only have a single developer license. This is a violation of our license term. You either need a corporate license or a separate developer license for each developer. See here for more details: https://www.essentialobjects.com/Products/EOPdf/EULA.aspxPlease contact the corresponding person in your company to remedy this situation as soon as possible, otherwise we will not be able to provide any additional support to you. One way to resolve this is to upgrade your single developer license to corporate license, which would cover unlimited developers for a single organization. You can also purchase additional developer licenses --- however that may not save much and would not protect you from additional users in the future. Please have someone in your company to contact us through our contact page for more details. Thanks!
|