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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux