Thursday, March 19, 2015

Memory gates checking failed and how to fix it in Dynamics CRM 2013

Pat for the 100th post :) Thank you all for liking what I do here and supporting indefinitely. Back to business....... :)

Pushing the limits comes with its own limitations. You can only go so far! This is the latest in the list of challenges after a long smooth running CRM at our client's.

I was reported that CRM wasn't saving any data as the Account and Opportunity forms data wasn't being saved. My first move was to check the Event viewer and I found this.

Exception: System.ServiceModel.ServiceActivationException: The service '//XRMServices/2011/Organization.svc' cannot be activated due to an exception during compilation.  The exception message is: Memory gates checking failed because the free memory (219115520 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.. ---> System.InsufficientMemoryException: Memory gates checking failed because the free memory (219115520 bytes) is less than 5% of total memory.
Since the SQL Server and CRM Server are running on the same server, this wasn't a surprise.



This pointed out something. I immediately looked up the Performance Monitor on the Task Manager and sure enough, the RAM was almost fully utilized (screenshot below).


Resolution

To get around this issue, I restarted the SQL Server Services and CRM Async Services. Since no users were logged in at this time, the usage went down to 3 GB. This I believe is a temporary fix and it would return when we have users log in again.

A permanent fix would be to separate the SQL Server and CRM Server and feed them with sufficient memory.

Another resolution I have been reading online is to adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.

This perhaps is the easiest way. The snippet to add into your web.config file is:
 <system.serviceModel>   
   <serviceHostingEnvironment minFreeMemoryPercentageToActivateService="0" />  
 </system.serviceModel>  
I am wondering how would this impact otherwise.