QByteArray maximum size
-
The size() function of QByteArray returns an int. The maximum value of an int is 2147483647 (which is 2GB) or unsigned 4294967295 (4GB). What happens if the size of the array is larger than that size, shouldn't it return a qint64? Or is it even possible to create QByteArrays larger than 2GB?
-
QByteArray supports up to 2GB of memory usage. Bigger blocks are not supported.
Note that it will be hard to even acquire such a huge continious memory block in one go on most systems today. If you need bigger structures, you probably will be better off using your own custom memory structure.
-
You are simply hit by a signed integer overflow and your number wraps around, actually passing <code>-1294967296</code> to the QByteArray constructor (the two's complement of <code>3000000000</code>), which leads to a zero-sized byte array (as a negative size is passed).
-
QBuffer works with qint64, and you can setBuffer(QByteArray). Does anyone know the behaviour if you now try to add more than 2GB to the QBuffer? Will it create a second QByteArray, or will it bomb out?
-
I currently only have 3GB memory on my workstation so I can't really test it. But thanks anyway, I don't think my program users will ever use more than 1GB or so.