2013-03-19 66 views
28

如何最終解決這個錯誤?IIS服務器錯誤,因爲當前總內存不足


'/ **** StatWCF_OData'應用程序中的服務器錯誤。

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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InsufficientMemoryException: Memory gates checking failed because the free memory (373817344 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. 

源錯誤:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

堆棧跟蹤:

[InsufficientMemoryException: Memory gates checking failed because the free memory (373817344 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.ServiceModel.Activation.ServiceMemoryGates.Check(Int32 minFreeMemoryPercentage, Boolean throwOnLowMemory, UInt64& availableMemoryBytes) +121924 
    System.ServiceModel.HostingManager.CheckMemoryCloseIdleServices(EventTraceActivity eventTraceActivity) +86 
    System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +883 

[ServiceActivationException: The service '/****StatWCF_OData/OData.svc' cannot be activated due to an exception during compilation. The exception message is: Memory gates checking failed because the free memory (373817344 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.Runtime.AsyncResult.End(IAsyncResult result) +650220 
    System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +210733 
    System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +282 

版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.17929

回答

82

解決方法寫在您的文章。

To resolve this, either reduce the load on the machine or adjust the value of minFreeMemoryPercentageToActivateService on the serviceHostingEnvironment config element.

最簡單的方法只需添加到這一點你的web.config

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

瞭解更多關於serviceHostingEnvironmenthere

無論如何,@Mr Grok正確指出這表示您的機器沒有足夠的物理內存,您應該弄清楚爲什麼會發生這種情況。這可能是一個嚴重的問題。

+10

雖然這將是最簡單的,但值得注意的是,如果您的服務器資源不足,這個錯誤可能表明您的機器上沒有足夠的物理內存,因此您可能會接近出現更大的問題在你的手上。檢查資源監視器/任務管理器以查看正在使用多少內存是非常值得的。 – 2013-09-27 09:17:41

+2

想知道爲什麼不是〜2%而不是0%?在0%的情況下,它不會將每個進程(可能至關重要)都放在服務器上,導致alloc失敗(可能未處理)的危險嗎?哦,「空閒內存」不包含虛擬內容(查看任務管理器顯示free = 0且提交= 8/13)?有人可以確認嗎? – crokusek 2015-02-20 19:19:23

5

我有這個問題。原來SQL服務器使用了超過29 GB的可用32 GB。

檢查您的SQL Server是否有。 MS SQL Sever旨在儘可能多地佔用您可用的空間。您可以將其限制在SQL Server屬性選項卡中的最大服務器內存框中。

0

我在web.config中將serviceHostingEnvironment屬性添加爲0。

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

這是我發現這樣做的最way way的方式。