Categories wcf

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

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:

<behavior name="">
<serviceMetadata httpGetEnable="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceHostingEnvironment minFreeMemoryPercentageToActivateService="1"/>

and the host web.config is

<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" />

How can I solve my problem?

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

<serviceHostingEnvironment minFreeMemoryPercentageToActivateService="0"/>

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