C# 数组、HashSet等内存耗尽的解决办法

在C#中,如果数据量太大,就会出现 'System.OutOfMemoryException' 异常。

解决办法来自于Stack Overflow和MSDN    https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/gcallowverylargeobjects-element

1.生成改为x64,即让程序运行在64位模式下(任务管理器里可以看到是否是32位的)。

2.配置文件添加<gcAllowVeryLargeObjects enabled="true|false" />

具体位置:<configuration> Element
<runtime> Element
<gcAllowVeryLargeObjects> Element

经过测试,确实没有再出现OutOfMemory的异常

 

posted @ 2017-12-15 14:24  Easy C#  阅读(1370)  评论(0编辑  收藏  举报