Pre loader

Reusing the data buffer in heatmap



I am using the 2D heatmap as follows:

mData = new double[dataSize, dataSize];
DataSeries = new Heatmap2DArrayDataSeries<int, int, double>(mData, x => x, y => y);

In my application the displayed data size can be changed by the users – e.g. 200 x 300, but there is also a known maximum size – e.g. 500 x 500 for the data. Since I would like to avoid unnecessary large object allocations, is there a way for me to reuse the data buffer and display only the required data?

I tried setting the visible range over the data that would need to be displayed, which worked, but unfortunately the performance is still the same as when rendering the maximum size image. Is there any other way to achieve the goal?

  • You must to post comments
Best Answer

Hi Rok,

How often are you changing data size? Why not pre-cache a few known sizes if you are concerned about memory allocation when changing size?

A 500×500 array is only 2MBytes and unless you are changing the size 60 times a second it shouldn’t be a problem.

  • Rok Rode
    Hi Andrew. The use case for us is that the user selects the size which can be anything up to maximum size and then do a measurement which can take up to a few minutes to complete. Also note that one measurement can produce several heatmaps in parallel, but the maximum number of displayed heatmaps will be capped due to performance reasons. The use case is similar to the sample I already emailed you a few months ago. So yes I agree that it should not be too big a deal to always allocate a new array, but it would be nice if it could be avoided. Is it also an option to implement IHeatmap2DArrayDataSeries on our own? For me ideally the implementation should not even be coupled to a specific array type but more to something like a data view interface like your I2DArraySegment. As mentioned … nice to have things, probably not really needed for our use case. :)
  • Andrew Burnett-Thompson
    OK understood. I would suggest looking into object pooling (if it is a performance drag to recreate arrays, if not, leave it!). With the SciChart Source Code, all things are possible. Without, implementing IHeatmap2DArrayDataSeries will be pretty difficult, I must admit !
  • Rok Rode
    I guess I will try it out as it is and if it becomes a problem implement the IHeatmap2DArrayDataSeries. Fortunately we have the source code, so it should be easier. Thanks for the help!
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies