这是我的代码:
public class Class1 { public int[][] binArray; public Class1() { binArray = new int[1000][]; for (int i = 0; i < 1000; i++) { binArray[i] = new int[61608]; } } }
class Program
{
static void Main(string[] args)
{
Class1 c1 = new Class1();
Class1 c2 = new Class1();
Class1 c3 = new Class1();
Class1 c4 = new Class1();
Class1 c5 = new Class1();
Class1 c6 = new Class1();
Class1 c7 = new Class1(); // Memory will run out at about this point
Class1 c8 = new Class1();
Class1 c9 = new Class1();
Class1 c0 = new Class1();
Console.WriteLine();
}
}
Class1 用于存储数组,我认为它会为 24GB 的内存机器获得足够的 61608*4 字节的内存碎片,为什么out of memory exception
在我初始化第 7 类时它仍然会抛出一个?