我正在尝试创建一个byte长度为s 的数组UInt32.MaxValue.这个数组本质上是一个小的(ish)内存数据库:
byte[] countryCodes = new byte[UInt32.MaxValue];
Run Code Online (Sandbox Code Playgroud)
但是,在我的机器上,在运行时,我得到一个System.OverflowException"算术运算导致溢出".
这是怎么回事?我需要使用unsafe块malloc吗?我怎么会在C#中做到这一点?
是否存在可以存储在List中的元素的限制?或者你可以保持添加元素直到你内存不足?
我有一个64位的VB.NET应用程序,并希望分配一个> 2GB的缓冲区.
在下面的代码中,"new"和"ReDim"都抛出"OverflowException".
当这些函数只接受带符号的32位值时,如何分配> 2GB的缓冲区?
(这可能在C#中?)
编辑 - 我正在运行带有4GB RAM的WinXP 64.
Dim width As Long = 19005
Dim height As Long = 32768
Dim buffer() As Byte = New Byte((width * height * 4) - 1) {}
Dim size As Long = (width * height * 4) - 1
ReDim buffer(size)