本文介绍了在C ++中创建太大的数组,如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
最近,我在C ++中工作,我必须创建一个数组[60.000] [60.000]
。但是,我不能创建这个数组,因为它太大。我尝试了 float **数组
或甚至 static float数组
但没有什么是好的。有没有人有一个想法?
感谢您的帮助!
Recently, I work in C++ and I have to create a array[60.000][60.000]
. However, i cannot create this array because it's too large. I tried float **array
or even static float array
but nothing is good. Does anyone have an ideas?Thanks for your helps!
推荐答案
大小 60,000 x 60,000
有 3,600,000,000
元素。
您使用的是 code>,因此变为:
You're using type float
so it becomes:
60,000 x 60,000 * 4 bytes = 14,400,000,000 bytes ~= 13.4 GB
请注意,堆栈与堆的问题甚至无关紧要,除非你有足够的内存开始。
Note that the issue of stack vs heap doesn't even matter unless you have enough memory to begin with.
以下是可能出现的问题列表:
- 如果矩阵是全局声明的,则会超出二进制文件的最大大小。
- 如果您正在编译32位元,就远远超过了2GB / 4GB的寻址范围。
- You don't have enough memory.
- If the matrix is declared globally, you'll exceed the maximum size of the binary.
- If the matrix is declared as a local array, then you will blow your stack.
- If you're compiling for 32-bit, you have far exceeded the 2GB/4GB addressing limit.
这篇关于在C ++中创建太大的数组,如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!