当前位置:编程学习 > C#/ASP.NET >>

c#中的gcAllowVeryLargeObjects和OutOfMemoryException

什么是gcAllowVeryLargeObjects
在.net4.5中新增一个配置项 “gcAllowVeryLargeObjects” ,msdn解释如下:

在64位平台上,可以允许总共大于2千兆字节的数组。(2GB)

具体说就是在.net中,List,Arrary, Dictiontry, HashSet, HashTable等列表和数组结构的对象内存可以超过2GB了。 在.net4.5之前,这些对象如果使用内存超过2GB,就会报OutOfMemoryException(内存溢出)错误。

 
如何使用?
在 yizuotu.exe.config文件中 设置如下,如果不存在的话,可以手动创建下。

复制代码
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <gcAllowVeryLargeObjects enabled="true" />
  </runtime>
</configuration>
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,