简体   繁体   English

2d数组“ std :: bad_alloc()” what()的运行时错误

[英]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^91.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.

相关问题 递归函数中的运行时错误:在抛出“std::bad_alloc”what() 实例后调用终止:std::bad_alloc - Runtime Error in a recursive function : terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc 收到错误“在抛出&#39;std::bad_alloc&#39;what() 的实例后调用终止:std::bad_alloc” - getting error "terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc" std::bad_alloc 运行时异常 - std::bad_alloc runtime exception C ++:what():std :: bad_alloc错误 - c++: what(): std::bad_alloc error Node.js错误“在抛出&#39;std :: bad_alloc&#39;的实例后调用终止what():std :: bad_alloc” - Node.js error “terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc” C++ 错误:在抛出 'std::bad_alloc' what(): std::bad_alloc 的实例后调用终止 - C++ error: terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc 如何修复 C++ 错误:在抛出“std::bad_alloc”实例后调用终止。 什么():std::bad_alloc - How to fix C++ error: terminate called after throwing an instance of 'std::bad_alloc'. what(): std::bad_alloc 从向量中删除指针...错误:在抛出“std::bad_alloc”实例后调用终止 what(): std::bad_alloc - Deleting a pointer from a vector... Error: terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc 这个 function 中 std::bad_alloc 的原因是什么? - What is the reason for std::bad_alloc in this function? 多个文件的 Memory 分配错误“在抛出 'std::bad_alloc' 的实例后调用终止什么 ():std::bad_alloc” [C ++] - Memory allocation error for multiple files “terminate called after throwing an instance of 'std :: bad_alloc' what (): std :: bad_alloc” [C ++]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM