c# – WCF服务在第一次调用时达到高内存使用率

c# – WCF服务在第一次调用时达到高内存使用率,第1张

概述我们有一个WCF服务作为BL服务. 该服务处于混合传输模式,具有超过10个不同的端点,由BasicHttpBinding绑定,具有不同的合同和所有这些的相同地址. 该服务在IIS-7上的应用程序池上运行. 问题是,服务工作正常,但是在第一次调用之后,即使获得WSDL,w3wp.exe的内存使用量也直接达到300兆,服务内存使用量不断增加,接管所有物理内存服务器(98 – 100%).我们没有内存异 我们有一个WCF服务作为BL服务.
该服务处于混合传输模式,具有超过10个不同的端点,由BasichttpBinding绑定,具有不同的合同和所有这些的相同地址.
该服务在IIS-7上的应用程序池上运行.

问题是,服务工作正常,但是在第一次调用之后,即使获得WSDL,w3wp.exe的内存使用量也直接达到300兆,服务内存使用量不断增加,接管所有物理内存服务器(98 – 100%).我们没有内存异常,但是这种情况会降低其他应用程序和服务的速度,因此我们需要每隔几天手动刷新一次应用程序池.
我已经尝试使用内存分析工具,但没有发现导致问题的原因.

有人遇到过这个问题吗?如果是的话,你做了什么?

附加信息:

> BL服务位于基于NHibernate的DAL框架之上,
我们已经排除了内存泄漏源于那里.
>配置文件

<?xml version="1.0" enCoding="utf-8"?><configuration>    <appSettings>    </appSettings>       <system.web>        <compilation deBUG="true" targetFramework="4.0" />        <httpRuntime maxRequestLength="20000" requestLengthdiskThreshold="20000" />    </system.web>         <system.serviceModel>             <behaviors>            <serviceBehaviors>                <behavior name="DefaultServiceBehavior">                    <serviceMetadata httpGetEnabled="true" />                    <serviceDeBUG includeExceptionDetailinFaults="true" />                </behavior>            </serviceBehaviors>             <endpointBehaviors>                <behavior name="AnonymousBehavior">                </behavior>            </endpointBehaviors>      </behaviors>      <bindings>          <basichttpBinding>              <binding name="SecureBinding"                closeTimeout="00:10:00"                openTimeout="00:10:00" receiveTimeout="00:10:00"                sendTimeout="00:10:00" allowcookies="true"                hostnameComparisonMode="StrongWildcard" maxBufferSize="65536000"                maxBufferPoolSize="524288000" maxReceivedMessageSize="65536000"                transferMode="Buffered">                  <readerQuotas maxDepth="20000000"                   maxStringContentLength="8192000"                   maxArrayLength="16384000"                   maxBytesPerRead="4096000"                   maxnametableCharCount="16384000" />                      <security mode="None">                          <transport clIEntCredentialType="None"/>                      </security>              </binding>         </basichttpBinding>             </bindings><services><service name="BL.Services.MyService"behaviorConfiguration="DefaultServiceBehavior"><endpoint address=""binding="basichttpBinding"bindingConfiguration="SecureBinding"bindingnamespace="Security/Anonymous"behaviorConfiguration="WithSecurityContextInspector"contract="BL.Services.Contracts.IAnonymousClaimsService" /><endpoint address=""binding="basichttpBinding"bindingConfiguration="SecureBinding"bindingnamespace="Domain/App"behaviorConfiguration="WithSecurityContextInspector"contract="BL.Services.Contracts.IAppService" /><endpoint address=""binding="basichttpBinding"bindingConfiguration="SecureBinding"bindingnamespace="Domain/App"behaviorConfiguration="WithSecurityContextInspector"contract="BL.Services.Contracts.IAttachmentService" /><endpoint address=""binding="basichttpBinding"bindingConfiguration="SecureBinding"bindingnamespace="Domain/Site"behaviorConfiguration="WithSecurityContextInspector"contract="BL.Services.Contracts.ISecurityService" /><endpoint address=""binding="basichttpBinding"bindingConfiguration="SecureBinding"bindingnamespace="Domain/Transaction"behaviorConfiguration="WithSecurityContextInspector"contract="BL.Services.Contracts.ITransactionService" /><endpoint address=""binding="basichttpBinding"bindingConfiguration="SecureBinding"bindingnamespace="Domain/ActiveDirectory"behaviorConfiguration="WithSecurityContextInspector"contract="BL.Services.Contracts.IActiveDirectoryService" /><endpoint address=""binding="basichttpBinding"bindingConfiguration="SecureBinding"bindingnamespace="Domain/Report"behaviorConfiguration="WithSecurityContextInspector"contract="BL.Services.Contracts.IReportService" /><host><baseAddresses><add baseAddress="//MyService.svc" /></baseAddresses></host></service></services><serviceHostingEnvironment multipleSiteBindingsEnabled="true" /></system.serviceModel><system.webServer><modules runAllManagedModulesForAllRequests="true" /><defaultdocument><files>    <add value="MyService.svc" /></files></defaultdocument></system.webServer></configuration>
解决方法 AnkMannen指出,300MB并不罕见.大量使用的服务可以轻松达到约700MB或更高的平台.您对耗尽大多数可用服务器内存但未触发内存不足异常的服务的第二次观察可能是由于非默认配置值:
binding:maxBufferSize="65536000"maxBufferPoolSize="524288000"maxReceivedMessageSize="65536000"transferMode="Buffered"readerQuotas:maxDepth="20000000"maxStringContentLength="8192000"maxArrayLength="16384000"maxBytesPerRead="4096000"maxnametableCharCount="16384000"

您实际上正在配置WCF以使用您选择的值消耗过多的内存.除非您遇到需要更改任何属性的默认值的特定条件,否则请勿更改它们.我常规更改的唯一值是maxReceivedMessageSize,默认值为64K,大约为1到2 MB,如果不可避免的话.如果您经常使用大于3 MB的邮件,则应重新考虑数据协定设计. WCF被指责的许多性能问题实际上是错误配置而不是WCF本身的性能问题.

总结

以上是内存溢出为你收集整理的c# – WCF服务在第一次调用时达到高内存使用率全部内容,希望文章能够帮你解决c# – WCF服务在第一次调用时达到高内存使用率所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1262274.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-08
下一篇 2022-06-08

发表评论

登录后才能评论

评论列表(0条)

保存