|
Memory leak on COM-version based pdf generation |
Posted by Daniel on Jun-23-2015 02:52 |
|
Hi Peter,
I have started to test the new 6.0 version. We use the COM version.
Our software extensively use CD, thousands lines of chart delivery code, including lots of CD functionality including complex D 'nd Drop interactions with the (init/remove) dynamicLayer functions and DrawArea-based additions to the generated output.
1- THE GREAT POINT: the whole 5.1-originated code base ran without a single flaw when building and delivering data to raster formats (we use PNG for viz and offer other bitmap formats as output). The performance seems unchanged. That's great. And we could take advantage of some of the new functionalities (roundedcorners comes to mind). We will use other new stuff later.
2-- I wanted to use the great pdf functionality but we found a series of glitches on the new PDF output: at first a few "cosmetic" mishaps that could possibly be tackled later and, more critical, one significant memory leak:
When outputing to pdf, the COM object does leak significantly on each makechart or makechart2 call. This happens exclusively on pdf output. I tried the SVG, another vectorial format (that we do not propose as output) and got not problem. All other formats (jpeg, gif, bmp) are unaffected.
This pdf rendering issue seems to happen on all our chart rendering scenarii.
Should you need a test case, I can try to deliver one. But that may not be necessary since it should IMHO possibly happen on quite trivial samples. We like what we see - the vectorial pdf - a lot! Since the leak is a relatively massive one, I hope that it means it may be debugged relatively easily.
Daniel |
Re: Memory leak on COM-version based pdf generation |
Posted by Daniel on Jun-23-2015 13:08 |
|
One additional minor point:
the leak does not occur when we insert setOutputOptions("bitmap") before generating the output itself with makeChart2(7) or makeChart("output.pdf").
Daniel |
Re: Memory leak on COM-version based pdf generation |
Posted by Peter Kwan on Jun-24-2015 01:01 |
|
Hi Daniel,
I have just tried myself with a simple test case, but I cannot found any memory leak.
Note that when the PDF is first created, ChartDirector will need to load and process the
font files, because in PDF, a subset of the fonts will need to be embedded in the PDF.
ChartDirector will cache the fonts in memory, so that the next time, it does not need to
load them from the hard disk and process them again. So it is normal the memory usage
will increase when the PDF is first created due to font loading and caching. If the code
then creates more PDF using the same fonts, the memory should not increase indefinitely.
It should stabilize. If this is the case, then it can be confirmed there is no memory leak.
The following is my test code. I write it for the Windows command line cscript VBScript
interpreter so any Windows machine should be able to run it. It runs in a loop. Everytime
the enter key is hit, it will create 100 PDF files for 100 bar charts, using different data
values but the same font.
To try it, please save the code in a file called "test.vbs", put it in a temporary directory
(because 100 files will be created), then open a command shell and run "cscript
test.vbs". Then open the Task Manager to monitor the memory of the cscript process.
The first time the enter key is hit, the memory usage will increase and 100 PDF files will
be created. You can then hit the key again to create another 100 PDF files (overwriting
the original 100 files as they use the same names), and then again and again. You should
found that the memory usage does not change significantly and the memory usage is
stable.
If the test code still cannot solve the problem, is it possible to provide a test case (the
test case should generate a lot of PDF repeatedly and not just create the PDF once) to
help us identify the issue?
'============== Test Code ================
Set cd = CreateObject("ChartDirector.API")
Do While True
WScript.StdOut.Write "Press Enter to Create 100 PDF Charts"
strInput = WScript.StdIn.ReadLine
For i = 0 To 100
' The data for the bar chart
data = Array(85, i * i Mod 156, 179.5, 211, i)
' The labels for the bar chart
labels = Array("Mon", "Tue", "Wed", "Thu", "Fri")
' Create a XYChart object of size 250 x 250 pixels
Set c = cd.XYChart(250, 250)
' Set the plotarea at (30, 20) and of size 200 x 200 pixels
Call c.setPlotArea(30, 20, 200, 200)
' Add a bar chart layer using the given data
Call c.addBarLayer(data)
' Set the labels on the x axis.
Call c.xAxis().setLabels(labels)
' Output the chart
Call c.makeChart("simplebar" & i & ".pdf")
Next
Loop
'============ End Of Test Code ==============
Regards
Peter Kwan |
Re: Memory leak on COM-version based pdf generation |
Posted by Daniel on Jun-24-2015 12:20 |
|
Hi Peter,
Thanks for attention and your easy test script.
The script is leaking on my current dev platform. The memory loss is certainly not as big as the one encountered with own production code - which produces heavy charts, as you might expect.
The cscript exe is running from an initial 13 Mb memory use to around 20 Mb in 10 runs (ie 10x 100 charts). Bumping more into the test script steadily aggravates the loss rapidly to over 100, 200 Ko and more. The loss is more steady than in my production environment (I am not using vb) but it is indeed happening as well in vbscript.
When one change the chart rendering line to 'Call c.makeChart("simplebar" & i & ".png")', the leak just doesn't happen, even you bump the test code hard; Zero leak even on hundreds of calls.
CD is a recent 6.0 download. I am at a loss. Using XP sp3 here with related stuff including cscript version. Could that be related to using such legacy OS software (see image).
Daniel
|
Re: Memory leak on COM-version based pdf generation |
Posted by Daniel on Jun-24-2015 12:22 |
|
Peter, sorry for the typing error:
"Bumping more into the test script steadily aggravates the loss rapidly to over 100, 200 Ko and more."
should read:
"Bumping more into the test script steadily aggravates the loss rapidly to over 100, 200 Mb and more."
Daniel |
Re: Memory leak on COM-version based pdf generation |
Posted by Peter Kwan on Jun-24-2015 19:31 |
|
Hi Daniel,
Thanks for the valuable information. I am now able to reproduce the memory leak. It should
allow us to fix it quickly, possibly within 24 hours. I will update this thread when the fix is
available.
Regards
Peter Kwan |
Re: Memory leak on COM-version based pdf generation |
Posted by Daniel on Jun-24-2015 21:01 |
|
Hi Peter,
That's great. I'm looking forward for the coming patch
Daniel |
Re: Memory leak on COM-version based pdf generation |
Posted by Peter Kwan on Jun-26-2015 00:38 |
|
Hi Daniel,
I have just uploaded the patch to:
http://www.advsofteng.com/chartdir60p1.zip
Please use the updated "chartdir60.dll" inside to replace your existing "chartdir60.dll". This
should fix the problem.
Note: If you are using ChartDirector for ASP/COM/VB with IIS, the IIS can "lock" the
"chartdir60.dll", preventing it to be overwritten. In this case, you may open a command
prompt and enter "iisreset" to cause IIS to reset and release the file so that you can
overwrite it.
Hope this can help.
Regards
Peter Kwan |
Re: Memory leak on COM-version based pdf generation |
Posted by Daniel on Jun-26-2015 14:10 |
|
Hi Peter,
The leak has disappeared. That's absolutely great.
You made my day (and more)! This says a lot about the quality of your service and, even more so, about advsofteng engineering:)
Daniel
As I mentioned early in the posts, there a few cosmetic quirks on vectorial, i.e. pdf and, possibly as well svg, output that will certainly be no problem on your side to clear.
I do want to pollute the forum with these side issues - even if they certainly matter in the end - and will send a list of these with visual elements as supporting material to support@advsofteng.net early next week. |
|