Reputation: 671
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?
Upvotes: 45
Views: 124593
Reputation: 3323
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
Upvotes: 56
Reputation: 4395
In our case, we had a Memory Leak. I would suggest a code revision, instead applying a web.config tweak.
Upvotes: 0
Reputation: 1554
There could be 3-4 possible reasons for the above error :
1) SQL using most of server space and you have not specified Max Server Memory Limit in SQL Server setting
2) Your system RAM is fully used.Some program using most of RAM for them to run.
3) IIS Application Pool is not recycled.
4) You have not specified "minFreeMemoryPercentageToActivateService" tag in your Web Service Web.Config file.You can add property in your Web.Config following way.
For Example : minFreeMemoryPercentageToActivateService="0"
Upvotes: 0
Reputation: 51
RECYCLE YOUR APP POOL
Upvotes: 5
Reputation: 31
This issue occurs if the RAM of your system is occupied for more than 95%, stop some unwanted processes and try invoking the service again.
Upvotes: 3
Reputation: 89
I used the Resource Monitor on my MS 2008 R2 Web Server to determine that SQL Server was consuming over 29 gigs of my available 32.
After reading others opinions on how much memory to allocate to SQL I set the max memory to 24 gigs. The max server memory limit can be found on the memory tab of your SQL Server properties.
Upvotes: 1
Reputation: 608
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...
Upvotes: 20
Reputation: 41
There are situations when changing the web.config is not an option. In our case we solved this by increasing the server's memory from 8GB to 16GB.
Upvotes: 4