[英]Runtime Error in a recursive function : terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
[英]Runtime error with 2d Array “std::bad_alloc()” what()
我已經動態分配了大小為1100 * 10 ^ 9的2D數組,並且遇到了以下運行時錯誤-
如果將數組的大小減小到1100 * 10 ^ 5,我不會遇到此錯誤。 請幫忙 。 提前致謝 。 編輯-我添加了分配數組的部分。
unsigned int** cache = new unsigned int*[1100] ;
for (int i = 0 ; i < 1100 ; i++)
cache[i] = new unsigned int [1000000000] ;
1100 * 10^9
是1.1*10^12
元素。 讓我們暫時假設這些元素是4字節整數,這是以下各項的總分配:
4.4 * 10^12
字節
除以1024 * 1024 * 1024得到千兆字節...
1,048,017.748 GB
大約一千兆字節。
我認為地球上任何地方都沒有可以解決(更不用說分配)這么多內存的處理器架構。
(盡管如果我對此有誤,我會着迷的!)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.