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. Limit on QRC item file size?
Forum Updated to NodeBB v4.3 + New Features

Limit on QRC item file size?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 644 Views 3 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.
  • MDCatoM Offline
    MDCatoM Offline
    MDCato
    wrote on last edited by
    #1

    I was wondering if there was a limit on how big a file you can add to the QResource, and I created a random data file that was only 256MB in size, but trying to compile it my computer ran OOM (32 GB RAM). Is there anyway to simply add a few flags or some other qt magic to let me compile this QRC file without the OOM problem?

    1 Reply Last reply
    0
    • MDCatoM Offline
      MDCatoM Offline
      MDCato
      wrote on last edited by
      #2

      This is how to reproduce the OOM

      testqrc2binary
      ├── data.bin
      ├── main.cpp
      ├── main.qrc
      └── testqrc2binary.pro
      
      $ dd if=/dev/urandom bs=$((1024*1024)) count=256 status=progress > data.bin
      $ cat main.cpp
      #include <QCoreApplication>
      #include <QFile>
      #include <QTimer>
      
      int main(int argc, char *argv[])
      {
          QCoreApplication a(argc, argv);
      
          QFile f("://data.bin");
          f.open(QFile::ReadOnly);
      
          QTimer::singleShot(250, &a, &QCoreApplication::quit);
          return a.exec();
      }
      $ cat main.qrc
      <RCC>
          <qresource prefix="/">
              <file>data.bin</file>
          </qresource>
      </RCC>
      $ cat testqrc2binary.pro
      QT -= gui
      CONFIG += c++11 console
      CONFIG -= app_bundle
      DEFINES += QT_DEPRECATED_WARNINGS
      SOURCES += main.cpp
      
      qnx: target.path = /tmp/$${TARGET}/bin
      else: unix:!android: target.path = /opt/$${TARGET}/bin
      !isEmpty(target.path): INSTALLS += target
      
      RESOURCES += \
          main.qrc
      
      kshegunovK 1 Reply Last reply
      0
      • B Offline
        B Offline
        Bonnie
        wrote on last edited by Bonnie
        #3

        try

        CONFIG += resources_big
        

        But it is not a good design to have so big resource since it will be compiled to your executable file.

        MDCatoM 1 Reply Last reply
        6
        • MDCatoM MDCato

          This is how to reproduce the OOM

          testqrc2binary
          ├── data.bin
          ├── main.cpp
          ├── main.qrc
          └── testqrc2binary.pro
          
          $ dd if=/dev/urandom bs=$((1024*1024)) count=256 status=progress > data.bin
          $ cat main.cpp
          #include <QCoreApplication>
          #include <QFile>
          #include <QTimer>
          
          int main(int argc, char *argv[])
          {
              QCoreApplication a(argc, argv);
          
              QFile f("://data.bin");
              f.open(QFile::ReadOnly);
          
              QTimer::singleShot(250, &a, &QCoreApplication::quit);
              return a.exec();
          }
          $ cat main.qrc
          <RCC>
              <qresource prefix="/">
                  <file>data.bin</file>
              </qresource>
          </RCC>
          $ cat testqrc2binary.pro
          QT -= gui
          CONFIG += c++11 console
          CONFIG -= app_bundle
          DEFINES += QT_DEPRECATED_WARNINGS
          SOURCES += main.cpp
          
          qnx: target.path = /tmp/$${TARGET}/bin
          else: unix:!android: target.path = /opt/$${TARGET}/bin
          !isEmpty(target.path): INSTALLS += target
          
          RESOURCES += \
              main.qrc
          
          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by kshegunov
          #4

          Or alternatively don't build the resource into the binary, but load it at runtime instead.

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          2
          • B Bonnie

            try

            CONFIG += resources_big
            

            But it is not a good design to have so big resource since it will be compiled to your executable file.

            MDCatoM Offline
            MDCatoM Offline
            MDCato
            wrote on last edited by
            #5

            @Bonnie said in Limit on QRC item file size?:

            CONFIG += resources_big

            Yeah thanks, that was exactly what I was looking for

            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