我试图通过WCF服务调用将大量数据保存到数据库中。我无法调用该服务。它抛出一个错误。
codeProxy.SaveCodes(requestHeader, codes, Rawcodes);
未能分配134217728字节的托管内存缓冲区。可用的内存量可能很低。
我已经将服务器和客户端上的web配置配置为最大限制。
客户端web.config
<binding name="WSHttpBinding_dataService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true"/>
</security>
</binding>
服务器web.config
<service name="ser.WSHttpBinding_dataService" behaviorConfiguration="ServiceBehavior">
<endpoint contract="ser.IDataservice" binding="wsHttpBinding" bindingConfiguration="datacodeservice" />
</service>
<wsHttpBinding>
<binding name="datacodeservice" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode ="None">
<!--<message clientCredentialType="Certificate" />-->
</security>
</binding>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
<serviceThrottling maxConcurrentSessions="100" />
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</serviceBehaviors>
发布于 2013-11-26 06:51:19
在WCF操作的消息契约中使用Stream属性来传输大对象。
[MessageContract]
public class DocumentDescription
{
[MessageBodyMember(Namespace = "http://example.com/App")]
public Stream Stream { get; set; }
}
以这种方式配置绑定
<binding name="Binding_DocumentService" receiveTimeout="03:00:00"
sendTimeout="02:00:00" transferMode="Streamed" maxReceivedMessageSize="2000000">
<security mode="Transport" />
</binding>
要将大型数据上载到Server数据库,请使用以下文章通过ASP.Net MVC从Server下载和上传图像中描述的方法
发布于 2014-06-11 14:47:53
如果您在.Net 2.0服务中遇到此问题,此修补程序可能会有所帮助
http://support.microsoft.com/kb/974065
问题 当您运行基于.NET Framework2.0的应用程序时,应用程序会崩溃.如果调试应用程序,则会注意到抛出了System.InsufficientMemoryException异常。然后,您将收到一条类似于以下内容的错误消息:未能分配字节的托管内存缓冲区。可用的内存量可能很低。 原因 问题1的原因 当应用程序试图为大对象堆(LOH)中的大型对象分配内存时,会间歇性地发生此问题。当下列条件为真时,将触发错误消息:堆不能提供足够的内存来满足LOH分配请求。同时正在进行并发垃圾收集。问题2的原因 发生此问题的原因是,对于小对象分配的垃圾收集器堆平衡没有在拥有8个以上逻辑处理器的计算机上执行。因此,当不同处理器的工作负载不平衡时,就会触发更多的垃圾回收来保持堆平衡。因此,应用程序花费更多的时间在垃圾收集上。
https://stackoverflow.com/questions/20209641
复制相似问题