I want to allocate about 10 GB of RAM. But I get an error message:
error C2148: the total size of the array must not exceed 0x7fffffff
my simplified code:
int main(){ char* myBuffer = new char[11000000000];
I am aware of the differences between x86 and x64 and the address size limit in x86. So I set my goal on x64. I also know about the size of the stack size, but keep in mind that I allocate a bunch.
It's amazing that when I use the code below and it compiled successfully.
#include <memory> int main(){ char* myBuffer = (char*) malloc(11000000000); //compiled successfully even much more than this size }
What is wrong with my code when I use the new operator?
Environment: Visual studio 2013 using an empty project, Windows 2008 R2 Datacenter server, 128 GB of RAM.
Edit: The link provided by nm does not fully answer my question. I also want to know why malloc works well, but not new ?
source share