High memory usage when compiling array of shared_ptr in gcc 4.6.2+
Philipp Savun
philipp.savun@gmx.de
Fri Apr 6 11:56:00 GMT 2012
Hello,
since version 4.6.2 I have the following problem when compiling a c++11
program with gcc:
When using an array with really many shared_ptr I am running out of
memory when compiling the code.
The the following error occurs:
"cc1plus: out of memory allocating 268435456 bytes after a total of
40083456 bytes"
on my computer having 4GM RAM.
This problem still exitst with gcc 4.7.
gcc 4.5.2 doesn't seem to use much memory at all - it also instantly
compiles that code (and much faster).
Someone who can explain the issue?
The code would be something like this:
#include <memory>
#include <array>
class SomeClass;
typedef std::shared_ptr<SomeClass> SomeClassPtr;
typedef std::array<SomeClassPtr, 3000*3000> MyArray;
int main()
{
MyArray myArray;
return 0;
}
This is the coomandline when compiling:
g++ main.cpp -std=c++0x
My system is "Linux Mint 11 Katya".
Thank you
Philipp
More information about the Gcc-help
mailing list