QCustomPlot Discussion and Comments

Max Number of Points?Return to overview

What is the max number of data points that can be plotted at any given time? Can the QCP handle a theoretically unlimited number of points?

This is probably more of a windows/Qt issue, but after ~10 million points I get a std::bad_alloc error and my program shuts down. 10 million points should be less than a GB of memory and my system has 10GB free at the time.

Hi Ben,

I've just tried it on my humble 8 GiB RAM (32-bit, so actually 4 GiB per process), and It fails only at 43.7 million data points due to a bad alloc (out of memory). And this is with Qt 5.3, so using the red-black-tree map structure. Of course having all of them on screen is sluggish as hell, but it doesn't throw a bad alloc if below 43 Million. At that point, the process uses 2.8 GiB of memory. So I'm not sure what's going on in your case, it sure isn't expected.

A change that will come in Version 2.0 of QCustomPlot is the trimming of the QCPData container to remove all the error variables that are not used in the majority of cases and thus waste memory (errorbar functionality will be preserved via an additional plottable). So you could try this to reduce the memory footprint of the graph. Strip off the

  double keyErrorPlus, keyErrorMinus;
  double valueErrorPlus, valueErrorMinus;

part, reducing your data point memory footprint by two thirds. You'll also have to get rid of/comment out the few code sections that use those variables. I suggest just removing the above lines from QCPData and then moving from syntax error to syntax error until it compiles. No hidden traps there.

Other hard-core users of QCP have converted the entire library to be float-based, gaining some speed and halving the memory footprint at the cost of number precision and maximum/minimum magnitude. But that might be a bit overkill to sort out your situation.

DerManu,
Thanks for the replay and the suggestions. I am excited for version 2!

I just re-spun my program to use floats and trimmed the error values and I am happy with the results.

I had the same problem with so many data points (4 * 4 million) in QCustomplot.
My programm uses also many memory for other data.

The suggestion to strip off the unused error values solve my problem too.
There where not so many changes in the QCustomplot lib.

Many thanks for this old post.
If i get time for my project i will update to version 2.x