Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QList bad_alloc error
FreshZone last edited by
I need your help, I'm using an QList to which I want to append up to 860 million elements. So i worte this code to test it:
But my program crashes (at line 2) and it get an error std::bad_alloc.
So I tried the same with QVector:
@ QVector<qint16> myData;
And I get the output from qDebug(): 860 Million entries.
Can someone tell me why this works with QVector, but fails with QList? And if there is a way I still can use the QList container?
860Million entries times 16bit equals to approx 1.7GB, which should be no problem for my PC.
Why I want to use QList:
Later in my program I'd like to use this List as container for my data. And I want to insert smaller lists the size of 4e6 elements and what I've read so far is, that the QList is better for inserting elements, is that true or false? If the later I could stick to QVector and forget about QList...