Running 'Gcc' on C++ Source File on Linux Gives "Cc1Plus: Out of Memory Allocating ..." Error Message

Running 'gcc' on C++ source file on Linux gives cc1plus: out of memory allocating ... error message

It turns out I had saved the C++ source file as a UTF-16 Unicode-encoded file, complete with leading Unicode Byte Order Mark (BOM) bytes at the beginning of the file. The file was saved as UTF-16 on a Windows system, committed to a version control system, then checked out to Linux. gcc does support Unicode encoded as UTF-8, but not Unicode encoded as UTF-16.

The solution was to convert the source file back to a standard, non-Unicode encoding.

How to diagnose g++ error cc1plus.exe: out of memory allocating 838860800 bytes in moderately sized project?

That happens when you try to compile a UTF-16 encoded file saved in Windows with gcc. Change encoding of your sources to UTF-8. See related CPP documentation.

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

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

C++11: g++-4.7 internal compiler error

It seems that your program requires an unreasonable amount of memory (perhaps because of too many template expansions).

Using a recent g++-trunk :

gcc version 4.8.0 20121026 (experimental) [trunk revision 192860] (GCC) 

with the following zsh limits:

   % limit          
cputime unlimited
filesize unlimited
datasize 15000MB
stacksize 8MB
coredumpsize 400MB
memoryuse 15000MB
maxproc 128166
descriptors 1024
memorylocked 64kB
addressspace 16000MB
maxfilelocks unlimited
sigpending 128166
msgqueue 819200
nice 0
rt_priority 0
rt_time unlimited

(this on Debian/Sid/AMD64 with i3770K intel processor & 16Gb RAM)

I am getting:

  % time g++-trunk -std=gnu++11 andrew.cc -o andrew
virtual memory exhausted: Cannot allocate memory
g++-trunk -std=gnu++11 andrew.cc -o andrew :
108.25s user 3.28s system 89% cpu 2:03.98 total

So it seems that template expansion requires so much memory that you program is not reasonable.

I'm not sure if this will be accepted as a GCC bug. The macro expansion for C++ templates is known to be Turing complete and you just hit the wall. And the GCC trunk does report a fatal, but understandable error.

The moral of the story might be to setrlimit(2) appropriately (with limits compatible with your system and hardware), perhaps using limit zsh built-in or ulimit bash built-in.

virtual memory exhausted: Cannot allocate memory

Since your compilation fails with out of memory, there's probably not enough memory to compile your program. This can't possibly be because of 'a session management problem' as suggested in the accepted answer. Is mysql eating more than it should? Is 300MB enough to compile C++ anyway?

Serving JSon (like for a REST interface) in Wt is done through a WResource bound to the WServer object. WApplication is for an interactive user interface.

Compiling C++ code makes the system hang

Do you realize how big these are?

bool win[1000000001];
bool know[1000000001];

Those are at least 1GB each!!! You're gonna want to allocate them dynamically...



Related Topics



Leave a reply



Submit