Results 1 to 6 of 6

Thread: Qt resources - cc1plus.exe:-1: error: out of memory allocating

  1. #1
    Join Date
    Jan 2014
    Posts
    76
    Thanks
    17
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Qt resources - cc1plus.exe:-1: error: out of memory allocating

    Hi,

    I try compile code where inside resources I have files which have +- 20MB and i get following error

    Qt Code:
    1. cc1plus.exe:-1: error: out of memory allocating 1073745919 bytes
    To copy to clipboard, switch view to plain text mode 

    It is a normal? Whether Qt Resources have some restrictions about size? Or it is a problem with my compiler? I use Qt 5.4 with ming 4.9.1

    Thanks,

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Qt resources - cc1plus.exe:-1: error: out of memory allocating

    The Qt resource compiler, rcc, converts the binary data in the .qrc resource file into unsigned char arrays in the qrc_[yourprojectname].cpp file, which is then compiled into an object file by the C++ compiler. This second step is what is blowing up on you. Your 20MB files are resulting in arrays that are too big for the compiler to build.

    There is a StackOverflow post that covers this (for MSVC compiler, but the issue and solution are the same). In short, you can't include resources of this size in the qrc file. You have to deliver them as external resources that are loaded at run time.

  3. The following user says thank you to d_stranz for this useful post:

    atomic (25th July 2015)

  4. #3
    Join Date
    Jan 2014
    Posts
    76
    Thanks
    17
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt resources - cc1plus.exe:-1: error: out of memory allocating

    Thanks that works fine but only for small / medium files.

    For example my qrc file looks like this

    Qt Code:
    1. <RCC>
    2. <qresource prefix="/">
    3. <file>ebook.pdf</file>
    4. <file>ebook2.pdf</file>
    5. <file>ebook3.pdf</file>
    6. <file>ebook4.pdf</file>
    7. <file>ebook5.pdf</file>
    8. <file>ebook6.pdf</file>
    9. <file>ebook7.pdf</file>
    10. <file>ebook8.pdf</file>
    11. <file>ebook9.pdf</file>
    12. <file>ebook10.pdf</file>
    13. </qresource>
    14. </RCC>
    To copy to clipboard, switch view to plain text mode 

    10 ebooks, +- 500MB

    and when i run rcc compiler by means of command

    Qt Code:
    1. rcc --binary --compress 9 resources.qrc -o ebooks.rcc
    To copy to clipboard, switch view to plain text mode 

    then I see dialog of windows application crash

    Qt Code:
    1. rcc.exe has stopped working...
    To copy to clipboard, switch view to plain text mode 

    I have a lot of memory so that is not a problem. I think that rcc compiler has some restrictions for files size but I do not know why... why? Why they can't handle file which have +-500MB ( or of course more ) Is there any way for solve this problem?

    For this file I think I can divide it on 10 parts and then create 10 rcc files... but what when I have one big file? One file which have 500MB? First divide this file on several small parts and then add to qt resource system? And on end user machine connect all parts to original file?

    Thanks,

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt resources - cc1plus.exe:-1: error: out of memory allocating

    Why would you want your executable to have several hundred megabytes, maybe even gigabytes in size?

    Startup time would be horrible.

    Cheers,
    _

  6. #5
    Join Date
    Jan 2014
    Posts
    76
    Thanks
    17
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt resources - cc1plus.exe:-1: error: out of memory allocating

    It is not my idea but that is one of requirements of project - one executable file which contains all dependencies.

    Startup time would be horrible.
    I have seen several files especially installers or archive of libraries which have similar ( often greater ) sizes and they startup time was a normal / fast.

    Thanks,

  7. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Qt resources - cc1plus.exe:-1: error: out of memory allocating

    I assume your compiler and rcc are 32-bit applications. On Windows this gives them a total memory allocation limit of 3GiB. Your compiler is choking trying to allocate a single chunk of memory circa 1GiB in order to slurp up the source file generated by rcc. I am not too surprised this failed either because there was not a GB to be had in total, or because there was not a GB of contiguous memory to be had.

    IIRC rcc converts each resource byte into a string "0xnn," to be part of a C++ source file. That is, there is a four/five fold increase in size over the original binary file size. Your 500MB turns into 2GB of source code. The compress option is of little use with PDFs because they are already compressed. This source is built into the executable/data sections of your executable.

    Installers and the like have a very small executable/data section and use other methods to embed data into the same executable file. They get at that data at run time by reading from the file, not by looking for an in-memory structure. I do not know if the Windows native resource system works this way. You might like this:
    http://stackoverflow.com/questions/2...sing-gcc-mingw

    BTW, I would still baulk at a 500MB executable.

Similar Threads

  1. Allocating memory for a windows structure
    By HyperEngineer in forum Newbie
    Replies: 2
    Last Post: 2nd June 2013, 15:34
  2. When does Qt release memory and resources?
    By jimc1200 in forum Newbie
    Replies: 2
    Last Post: 24th April 2012, 00:09
  3. Do resources in QRC files consume memory?
    By TheNewGuy in forum Newbie
    Replies: 1
    Last Post: 7th December 2009, 08:07
  4. cc1plus.exe: out of memory allocating 65536 bytes
    By DirtyBrush in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2009, 08:35
  5. How to solve this cc1plus: out of memory problem?
    By triperzonak in forum Qt Programming
    Replies: 2
    Last Post: 28th September 2008, 20:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.