Wednesday, April 1, 2015

'Memory gates checking failed because the free memory WCF' FIX: InsufficientMemoryException

You're getting ready to run your WCF service application and you see this error: "Memory gates checking failed because the free memory" populate in your browser.

Memory gates checking failed because the free memory (9338880 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.


This exception is simply caused by insufficient memory allocated to the WCF service at the current moment, thus, the application throws an "InsufficientMemoryException." Thankfully, the exception is descriptive enough to provide additional information on solving the issue.

Stack Trace Exception:
[InsufficientMemoryException: Memory gates checking failed because the free memory (9338880 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.]

FIX:

In your web.config look under configuration / system.serviceModel / serviceHostingEnvironment element. Add a minFreeMemoryPercentageToActivateService attribute and set it to zero (0). 

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

PS: If the serviceHostingEnvironment already exist, simply append/add the "minFreeMemoryPercentageToActivateService" attribute and set it to zero (0). 

Join the discussion on StackOverflow

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. I wouldn't trust IIS to not gobble up the rest of the memory you give it access to and compromise the whole machine. Usually restarting IIS claws back the excessive memory it grabs and gives enough relief to continue running.

    ReplyDelete