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" />
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<gcAllowVeryLargeObjects enabled="true" />
</runtime>
</configuration>
经过测试,确实没有再出现OutOfMemory的异常