【发布时间】:2016-08-07 23:13:17
【问题描述】:
我收到错误消息:
引发了“System.OutOfMemoryException”类型的异常。
尝试时:
try
{
var dict = new Dictionary<int, int>();
for (int i = 0; i <= Int32.MaxValue; i++)
{
dict.Add(i, i);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
我的系统大约在 30 秒内转储。
我的系统:
我的问题:要存储 2147483647 + 1 = 2147483648 元素(并且什么都不做),.Net 是否需要超过 2Gb 的 RAM?贵吗?
【问题讨论】:
标签: c#