Memory gates checking failed because the free memory (n bytes) is less than 5% of total memory.

Ever had this horrendous error?

WebHost failed to process a request.
 Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/45653674
 Exception: System.ServiceModel.ServiceActivationException: The service '/YourServiceName.svc' cannot be activated due to an exception during compilation.  The exception message is: Memory gates checking failed because the free memory (186429440 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 (186429440 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.
   at System.ServiceModel.Activation.ServiceMemoryGates.Check(Int32 minFreeMemoryPercentage, Boolean throwOnLowMemory, UInt64& availableMemoryBytes)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CheckMemoryCloseIdleServices(EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   --- End of inner exception stack trace ---
   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
   at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath, EventTraceActivity eventTraceActivity)
 Process Name: iisexpress
 Process ID: 992

If you don’t want to scroll, the relevant part is:

Memory gates checking failed because the free memory (n bytes) is less than 5% of total memory.

That is indeed an ugly error to see. Its precursor is that you sit waiting all day for your computer to do anything at all. Switching between windows becomes a 30 minute task. It also takes about 30 minutes to write a single line of code, if you’re lucky. (And 10 minutes before the debugger launches your code.)

I’m getting more RAM tomorrow, but should you also need to run a webservice despite all your common sense telling that there isn’t enough memory to do so, just add this to the system.serviceModel section of your config file:

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0" />

Again, if you are as lazy to scroll as I am to wrap that to more than one line, the relevant part is:

minFreeMemoryPercentageToActivateService=”0″

About Jerome

I am a senior C# developer in Johannesburg, South Africa. I am also a recovering addict, who spent nearly eight years using methamphetamine. I write on my recovery blog about my lessons learned and sometimes give advice to others who have made similar mistakes, often from my viewpoint as an atheist, and I also write some C# programming articles on my programming blog.
This entry was posted in Programming, Work and tagged , , . Bookmark the permalink.

2 Responses to Memory gates checking failed because the free memory (n bytes) is less than 5% of total memory.

  1. mom says:

    Hello Jerome: Remember one step at a time. Even if you stumble, do not blame yourself (no one is perfect) but just get back on track. As for atheist, well I could go either way ( Although I think we as a race know very little about the nature of reality – I am not saying to embrace anything but do not close yourself off from the beliefs of other people, (hear, think, learn)

    Liked by 1 person

    • Jerome says:

      Hi. I seldom check the comments on this blog… maybe you meant to post to the other one? (skepticalexaddict.wordpress.com)

      But thank you for your kind words. I’m doing well, and at the time of writing this I am 2 months shy of being 4 years clean. As for my atheism, I am always open to evidence of the supernatural… I just haven’t seen any. My position is one that I arrived at after years of being fascinated by the occult, religion, the paranormal, and so on, and seeking knowledge in all of those things. I just didn’t find any knowledge. I found nothing but bullshit so far.

      Like

Leave a comment