ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Heap memory usage
Posted by Stephan on May-22-2015 20:05
Hello,

there have already been a few questions about heap and memory usage of Chart Director. However I did not find one that does answer all my questions.

I work with Chart Director 5.1.1 in C++ together with Qt. During testing of our application I made a heap memory analysis with valgrind and it's massif tool.

In detail, I am drawing a XYChart with 900 x 491 pixels. I have 8 distinct lines to be drawn, each one has about 255590 data points. All read out of a database, then put into double arrays for CD, and finally drawn.

So, 8 x 255590 = 2044720 datapoints in total, and a double takes 8 bytes, so roughly 15.6 Mb of data. This is also what valgrind massif is telling me.

Then the data is passed in double arrays to CD, valgrind massif then tells me that libchartdir is using 29.6 Mb in a first step, and then 66.2 Mb in a second step, hence 95.8 Mb in total, to draw that chart.

When using LineLayer.setFastLineMode(), CD still uses 29.6 Mb for the first step, but only 41.3 in the second, hence 71.2 Mb in total.


I know, 255590 datapoints is a lot, but I anyway, I wonder why CD is using 71.2 MB, or 95.8 Mb, to draw the chart ?


Thank you in advance for your help,

Stephan

  Re: Heap memory usage
Posted by Peter Kwan on May-23-2015 00:01
Hi Stephan,

In the simplest case, your data contains 2 million points, and it takes around 16 Mb to store
the data values. However, you probably only count the y-coordinates. ChartDirector allows
you omit the x-coordinates, but internally it needs x-coordinates as well (which will
automatically be generated if not provided by your code). These are data coordinates only.
To plot them, ChartDirector needs another 2 million x pixel coordinate and y pixel
coordinates for the points. However, each point may not be just a point on the chart. It
may be a "shape" (a line segments for line layer, polygons for scatter layers, regions for
area layers, etc). So there are 2 million shapes. ChartDirector may need to remember at
least some parameters of the shapes (such as the bounding box of the shapes) them in
case you need to generate the image map or hot spots or perform some mouse interactions
for those 2 million points.

From your record, ChartDirector uses less than 100M bytes to process 2M points, so it is 50
bytes per point. I have not counted exactly how ChartDirector uses the memory, but in my
opinion, this is quite reasonable and not excessive, as each data point and has x and  data
coordinates and x and y pixel coordinates, and the point is not just a point on the chart,
but a "shape", which must be keep track of in order to support user interactions.

Hope this can help.

Regards
Peter Kwan