问题是关于.net中数组的分配.我有一个示例程序,其中我可以得到的最大数组是长度.我将长度增加到+1它给出了outofMemory异常.但如果我保持长度并删除评论,我可以分配2个不同的大数组.两个数组的.net允许对象大小为2 gb,总内存也小于虚拟内存.有人可以提出任何想法吗?
class Program
{
static int length = 203423225;
static double[] d = new double[length];
//static int[] i = new int[15000000];
static void Main(string[] args)
{
Console.WriteLine((sizeof(double)*(double)length)/(1024*1024));
Console.WriteLine(d.Length);
//Console.WriteLine(i.Length);
Console.WriteLine(Process.GetCurrentProcess().VirtualMemorySize64.ToString());
}
}
Run Code Online (Sandbox Code Playgroud)