I encounter a problem with the allocation of large arrays.
If I allocate an array of almost 2GB memory an bad_alloc exception is thrown.
What is the problem? Any idea?
My system is Win 7 64bit, 8GB RAM.
But I'm compiling with the MS Visual Studio 32bit.
I wonder about that because I would expect this problem somewhere around the typical 32bit limit of 3.2GB.
> If I allocate an array of almost 2GB memory an bad_alloc exception is thrown.
> But I'm compiling with the MS Visual Studio 32bit.
> I wonder about that because I would expect this problem somewhere
> around the typical 32bit limit of 3.2GB.
Around the typical limit of std::numeric_limits<std::ptrdiff_t>::max()
1 2 3 4 5 6 7 8
#include <iostream>
#include <limits>
int main()
{
std::cout << std::numeric_limits<std::ptrdiff_t>::max() << '\n' ;
// 2147483647 with 32 bit pointers
}