QCustomPlot Discussion and Comments

std::bad_alloc - Maximum number of points?Return to overview


I need to plot 60minutes of real time data comming at 100kHz. That is 360millions samples. The value range is from 10E-9 to 10. Is it possible with QCustomPlot? I'm facing memory allocation issue at arount 350MBytes of ram used.... I should be able to use at least 1GBytes with a 32bits machine, no?

Is there strategy to reduce memory usage? Or to store data more efficiently?

I have been able to plot 33554430 points before crash in release mode. The previous number was in debug mode.

One sample has two doubles in them (x and y), thus 2*64bit = 16 byte.
You have 360 000 000 * 16 byte = 5.4 Gigabytes.

Further, For cache-performance reasons, QCustomPlot tries to allocate contiguous memory. So it might be down to memory fragmentation why it can't allocate more. You could try splitting up into chunks of, say 500 000 points and creating a QCPGraph for each chunk – see if that allows you to allocate more.
Overall, on a 32 bit architecture, I wouldn't recommend holding this much memory. You should unload most of it on disk, and load it on-demand. (I know that's a bit tedious and makes the user wait sometimes until the next data is loaded, but with 350m points, I'd say you are already a bit above the limits of what's possible without swapping. And thanks to SSDs, it's by far not as bad as it used to be.)

Thanks for your quick answer. Actually I'm using a 64bit machine but Qt 64bit for windows seems to be not very supported...
I will investigate Graph splitting and/or on-demand loading from disk.
Anyway, this lib is great! Well done!