Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF service with Full Memory Error (Memory gates checking failed because the free memory) - How to resolve

Tags:

asp.net

wcf

I have a WCF service host. My request from wc is high. My host, after a period of time exhibits a problem of memory is full. This problem is repeated. When I open the Web Service help page, this error is shown:

Memory gates checking failed because the free memory (1398493184 bytes) is less than 5% of total memory. As a result, the service will not be available for incoming requests. To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.

My web.config from the WCF host is as follows:

<system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="">   <serviceMetadata httpGetEnable="true"/>   <serviceDebug includeExceptionDetailInFaults="false"/>   <serviceHostingEnvironment minFreeMemoryPercentageToActivateService="1"/> </behavior> </serviceBehaviors> 

and the host web.config is

<system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_IPaperService" clouseTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisojnMode="StringWildcard" maxBufferSize="1000000000" maxBufferPoolSize="1000000000" maxReceivedMessageSize="100000000" messageEncoding="text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="1000000000" maxArrayLength="1000000000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />   <security mode="None">   <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>   <message clientCredentialType="UserName" algorthmSuite="Default" />   <security> </binding> 

How can I solve my problem?

like image 868
Masoud Sadeg Avatar asked Apr 20 '13 11:04

Masoud Sadeg


2 Answers

Try setting minFreeMemoryPercentageToActivateService to 0 in your web.config for WCF Host, as suggested in this answer

<system.serviceModel>     <serviceHostingEnvironment minFreeMemoryPercentageToActivateService="0"/> </system.serviceModel> 

Edit 1: this provides a workaround but does not address the root cause. Depending on your specific situation this may or may not be good enough.

Edit 2: as correctly pointed out in comment by @radderz "The 'serviceHostingEnvironment' element needs to be a child of 'system.serviceModel'", see MSDN documentation

like image 111
Andrea Scarcella Avatar answered Sep 18 '22 04:09

Andrea Scarcella


instead of changing WCF config value, Try to know which process workingset memory high, try see that if its really requires

Powershellcommand>> get-process | Sort-Object WS -desc >c:\process.txt  

Also to know whether which processid is pointing to IIS App pool

cmd.exe>> %systemroot%\system32\inetsrv\AppCmd.exe list wp  

By allowing zero in config, this might be able to activate may corrupt the state of service for memory not available reason - that could be not so straight forward in nature :(

My 2 cents...

like image 32
HydPhani Avatar answered Sep 21 '22 04:09

HydPhani