CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2013
    Posts
    75

    How on earth does this require 3.1GiB of RAM?!?

    Apparently GCC requires 3.1GiB of RAM to compile this simple program...

    Code:
    #include <iostream>
    #include <future>
    using std::cout;
    using std::endl;
    using std::future;
    using std::async;
    
    int sum()
    {
    	int s =0;
    	for(int i =1; i < 100; i++)
    	s +=i; 
    	return s;
    }
    
    int main ()
    {
    	cout << "Starting thread!" << endl;
    	future<int> s = async(sum);
    	cout << "Sum is: " << s.get() << endl;
    	return 0;
    }
    Code:
    cc1plus: out of memory allocating 3355443200 bytes after a total of 570196 bytes
    Huh?

  2. #2
    Join Date
    Dec 2013
    Posts
    75

    Re: How on earth does this require 3.1GiB of RAM?!?

    Just need to get a microSD card and buy the ROEHSOFT Memory Expander from Google Play. Then it should work.

    The multi-threading component of the stdlib is 64-bit, so my 2GB 32-bit system runs out of RAM when the compiler allocates memory.

  3. #3
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: How on earth does this require 3.1GiB of RAM?!?

    it shouldn't matter if you have only 2Gb of physical RAM. That's why systems have virtual RAM. Unless you disabled this in windows which is a terribad idea.

    Lower amounts of physical RAM may end up making this run slower though.

    I'm not sure how you think a microSD and a memory expander are going to solve anything. Your 32Bit windows will still only allow 2Gb per process anyway (3G with a special setting).


    Best advice: post on the GCC forums/bugtracker. If the above snippet of code fails that way, it's likely there's a bug in there somewhere.

  4. #4
    Join Date
    Dec 2013
    Posts
    75

    Re: How on earth does this require 3.1GiB of RAM?!?

    I'm writing and running this on my Samsung S4.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured