[英]Runtime error with 2d Array “std::bad_alloc()” what()
I have dynamically allocated a 2D array of size 1100*10^9 and I am getting the following runtime error - 我已经动态分配了大小为1100 * 10 ^ 9的2D数组,并且遇到了以下运行时错误-
This is the runtime error 这是运行时错误
I don't encounter this error if I decrease the size of the array to 1100*10^5 . 如果将数组的大小减小到1100 * 10 ^ 5,我不会遇到此错误。 Please Help .
请帮忙 。 Thanks in advance .
提前致谢 。 Edit - I have added the part where I allocate the array.
编辑-我添加了分配数组的部分。
unsigned int** cache = new unsigned int*[1100] ;
for (int i = 0 ; i < 1100 ; i++)
cache[i] = new unsigned int [1000000000] ;
1100 * 10^9
is 1.1*10^12
elements. 1100 * 10^9
是1.1*10^12
元素。 Let's for a moment assume that these elements are 4-byte integers, that's a total allocation of: 让我们暂时假设这些元素是4字节整数,这是以下各项的总分配:
4.4 * 10^12
bytes 4.4 * 10^12
字节
dividing by 1024 * 1024 * 1024 to get gigabytes... 除以1024 * 1024 * 1024得到千兆字节...
1,048,017.748 GB
- which is about a thousand terabytes. 1,048,017.748 GB
大约一千兆字节。
I don't think there is a processor architecture anywhere on the planet which can address, let alone allocate, this much ram. 我认为地球上任何地方都没有可以解决(更不用说分配)这么多内存的处理器架构。
(although if I'm wrong about this I'd be fascinated to hear it!) (尽管如果我对此有误,我会着迷的!)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.