This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: High memory usage when compiling array of shared_ptr in gcc 4.6.2+


Hi Philipp,

I'd say that's sloppy coding (in my opinion).
You should really use malloc for huge buffers, not statically allocated variables.


Love,
Jens


On Fri, 06 Apr 2012 13:56:08 +0200, Philipp Savun wrote:
> 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
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]