无法分配 134217728 字节的托管内存缓冲区.可用内存量可能不足 [英] Failed to allocate a managed memory buffer of 134217728 bytes. The amount of available memory may be low

查看:39
本文介绍了无法分配 134217728 字节的托管内存缓冲区.可用内存量可能不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过 WCF 服务调用将大量数据保存到数据库中.我无法调用该服务.它抛出一个错误.

codeProxy.SaveCodes(requestHeader, code, 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"/><reliableSessionordered="true" inactivityTimeout="00:10:00" enabled="false"/><安全模式=无"><transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/><message clientCredentialType="Windows"negotiationServiceCredential="true" algorithmSuite="Default"establishSecurityContext="true"/></安全></binding>

服务器 web.config

<endpoint contract="ser.IDataservice" binding="wsHttpBinding" bindingConfiguration="datacodeservice"/></服务><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"/><reliableSessionordered="true" inactivityTimeout="00:10:00" enabled="false"/><安全模式=无"><!--<message clientCredentialType="Certificate"/>--></安全></binding><服务行为><行为名称=服务行为"><serviceDebug includeExceptionDetailInFaults="true"/><serviceMetadata httpGetEnabled="true"/><serviceThrottling maxConcurrentSessions="100"/><dataContractSerializer maxItemsInObjectGraph="2147483646"/></行为></serviceBehaviors>

解决方案

如果您在 .Net 2.0 服务上遇到此问题,此修补程序可能会有所帮助

http://support.microsoft.com/kb/974065

<块引用>

问题

当您运行基于 .NET Framework 2.0 的应用程序时,应用程序崩溃.如果您调试应用程序,您会注意到一个抛出 System.InsufficientMemoryException 异常.那么你收到类似于以下内容的错误消息:无法分配一个字节的托管内存缓冲区.可用数量内存可能不足.

原因

问题 1 的原因

当应用程序尝试为大对象堆 (LOH) 中的大对象分配内存.这当以下条件为真时,会触发错误消息:堆不能提供足够的内存来满足 LOH 分配要求.并发垃圾收集同时进行时间.问题 2 的原因

出现这个问题是因为垃圾收集器堆平衡小对象分配不是在具有超过 8 个逻辑处理器.正因为如此,更多的垃圾当有一个集合时,会触发集合以保持堆平衡不同处理器的工作负载不平衡.因此,应用程序在垃圾收集上花费更多时间.

I am trying to save a huge data to database through a WCF service call. I am not able to invoke the service. Its throwing a error.

codeProxy.SaveCodes(requestHeader, codes, Rawcodes);

Failed to allocate a managed memory buffer of 134217728 bytes. The amount of available memory may be low

I have configued the web config on server and client side to max limits.

client 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>

server 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>

解决方案

If you encounter this issue on a .Net 2.0 service this hotfix may help

http://support.microsoft.com/kb/974065

Issue

When you are running a .NET Framework 2.0-based application, the application crashes. If you debug the application, you notice that a System.InsufficientMemoryException exception is thrown. Then, you receive an error message that resembles the following: Failed to allocate a managed memory buffer of bytes. The amount of available memory may be low.

CAUSE

Cause of Issue 1

This issue occurs intermittently when the application tries to allocate memory for a large object in a large object heap (LOH). The error message is triggered when the following conditions are true: The heap cannot provide sufficient memory to satisfy the LOH allocation request. A concurrent garbage collection is in progress at the same time. Cause of Issue 2

This issue occurs because garbage collector heap balancing for small object allocations is not performed diligently on computers that have more than 8 logical processors. Because of this, more garbage collections are triggered to maintain heap balancing when there is an unbalanced workload in different processors. Therefore, the application spends more time on garbage collection.

这篇关于无法分配 134217728 字节的托管内存缓冲区.可用内存量可能不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆