【发布时间】:2013-06-12 21:56:32
【问题描述】:
我的服务器上出现此错误。
System.InsufficientMemoryException,mscorlib,版本=4.0.0.0, 文化=中立,PublicKeyToken=b77a5c561934e089
未能分配 536870912 字节的托管内存缓冲区。这 可用内存量可能很低。
这发生在最后一个语句return myCollection 之后。当 myCollection 大约有 45k 个项目时。
服务器配置:
<binding name="LargeTCPBinding"
closeTimeout="00:30:00"
openTimeout="00:30:00"
receiveTimeout="01:00:00"
sendTimeout="01:00:00"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="Windows" />
</security>
</binding>
我做了一些基本的内存分析GC.GetTotalMemory(false),将我的集合放入内存后的差异约为 170 MB。
返回集合后发生异常(因此它似乎发生在缓冲发送期间)。
如果我将我的 wcf 连接配置切换到 Streamed,这会修复异常,但通话会从 25 秒变为 1:05 分钟。
只是想了解这里发生了什么,因为该集合并没有那么大。这是在 WCF 4.0、64 位 cpu 上运行的。
【问题讨论】:
标签: c# performance wcf memory