Francesco Bonizzi
Francesco Bonizzi

Reputation: 5302

Qt compiling error: "out of memory allocating 134 MB" "cc1plus.exe not found"

I'm developing a Windows game that needs a lot of small different images, that I put in resources.qrc, they are in tot. 14 MB.

When I try to compile the only error is: "out of memory allocating 134 MB" "cc1plus.exe not found".

How can I handle this?

Upvotes: 9

Views: 14903

Answers (4)

M_M
M_M

Reputation: 2105

Don't forget the obvious either: The message might actually be true and you really don't have enough memory, or the memory can't be made available for the process that needs it.

I've got 16GB of RAM on my system which ought to be plenty for my small application. "It can't possibly be that." I thought... but my machine hadn't been restarted in weeks.

A system restart is all it took to fix this error for me.

Upvotes: 1

Vladimir
Vladimir

Reputation: 326

Windows 7SP1 x86 4 GB RAM

Qt 5.7.0

I had the same problem, when I added big file in resources in Qt. I had the error:

cc1plus.exe:-1: error: out of memory allocating 1073745919 bytes

Solution:

Add CONFIG += resources_big into the *.pro file.

I took it here: cc1plus.exe: out of memory | 60MB encrypted resource file

Upvotes: 13

Rinat
Rinat

Reputation: 2021

Well, I had this problem too. But in my situation putting all resources into .exe was necessary.

After this error I bought additional RAM (project is very important) and then my RAM became 12 GB (from 6 GB).

But I was very surprised when error hadn't disappeared :) After some googling, finally, I found answer there. The problem is cc1plus.exe executable memory limit. So, in case of Qt this problem can be solved in these steps (for Windows 7, MinGW32 4.9.2, for others probably simply needs to change paths):

  1. If your OS is 32 bit, then in cmd (as Admin) put bcdedit /set IncreaseUserVa 3072
  2. Install masm32;
  3. Open cmd (as administrator too);
  4. Put cd C:\Qt\Tools\mingw492_32\libexec\gcc\i686-w64-mingw32\4.9.2
  5. Put C:\masm32\bin\editbin.exe /LARGEADDRESSAWARE cc1plus.exe

That's all.

Upvotes: 6

Ferenc Deak
Ferenc Deak

Reputation: 35448

Don't put them in the qrc, keep them as individual resources (or a new qrc file for each of the image), and just load them on application startup. Qt generates a qrc_XXXXX.cpp file where it effectively inserts the binary data in form of char array of ALL your resources in the resource fileXXXXX in this file (yes, ONE array for your images of 14MB, ie: 14680064 bytes (written as hex (0xXX) bytes into 1 file... it will be big!), highly possibly poor compiler just coughs on them...

Upvotes: 9

Related Questions