Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QByteArray Class Maximum size and out-of-memory conditions is 2GB??
Forum Updated to NodeBB v4.3 + New Features

QByteArray Class Maximum size and out-of-memory conditions is 2GB??

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 823 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • stackprogramerS Offline
    stackprogramerS Offline
    stackprogramer
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • stackprogramerS Offline
        stackprogramerS Offline
        stackprogramer
        wrote on last edited by
        #3

        @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

        S 1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          6
          • stackprogramerS stackprogramer

            @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

            S Online
            S Online
            SimonSchroeder
            wrote on last edited by
            #5

            @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 to qsizetype.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved