QByteArray Class Maximum size and out-of-memory conditions is 2GB??
-
QByteArray Class Maximum size and out-of-memory conditions are 2GB??
Is there any way that I can increase the maximum size to 4 GB???
How can I solve this limitation...https://doc.qt.io/qt-5/qbytearray.html
Maximum size and out-of-memory conditions
The current version of QByteArray is limited to just under 2 GB (2^31 bytes) in size. The exact value is architecture-dependent, since it depends on the overhead required for managing the data block, but is no more than 32 bytes. Raw data blocks are also limited by the use of int type in the current version to 2 GB minus 1 byte. -
@stackprogramer said in QByteArray Class Maximum size and out-of-memory conditions is 2GB??:
How can I solve this limitation...
Use another container or upgrade to Qt6.
And you're really sure that you have more than 2GB of contiguous memory in all of your systems? -
@Christian-Ehrlicher said in QByteArray Class Maximum size and out-of-memory conditions is 2GB??:
contiguous
Hi, Thanks very much for my case I need 4 GB contiguous memory for reading a large binary file, (I was informed that RAM is 12GB, But QBytearray limitation is bullshit...)
But I think as soon as I should switch to Qt6.best regards sp
-
And why do you need all 4GB of this file in the memory? Even if you've 12GB of RAM this doesn't mean you have 4GB of contiguous memory... you for sure simply don't need all this in the RAM. See also QFile::map() for this task.
-
@Christian-Ehrlicher said in QByteArray Class Maximum size and out-of-memory conditions is 2GB??:
contiguous
Hi, Thanks very much for my case I need 4 GB contiguous memory for reading a large binary file, (I was informed that RAM is 12GB, But QBytearray limitation is bullshit...)
But I think as soon as I should switch to Qt6.best regards sp
@stackprogramer said in QByteArray Class Maximum size and out-of-memory conditions is 2GB??:
But QBytearray limitation is bullshit...
Qt started in a time when there were no harddisks with 4GB available – let alone RAM with 4GB. Also, all Intel (and compatible processors) were 32-bit or less. It would still take years for processors (and compilers) to support 64 bit integers. This – combined with longstanding compatibility of the API – are all very, very good reasons to have the limit at 4GB (or 2GB because of signed-ness – which I really like about Qt compared to STL – in the case of Qt).
You are right that nowadays this limit is a handicap. Though, one should never easily change the API. Now, this has been done with Qt 6. This makes me not want to switch to Qt 6... :( It's gonna be a lot of work changing
int
in the right places toqsizetype
.