【问题标题】:IIS Server error because of the current total memory由于当前总内存导致 IIS 服务器错误
【发布时间】:2013-03-19 10:46:30
【问题描述】:

如何最终解决这个错误?


“/****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

【问题讨论】:

    标签: iis memory


    【解决方案1】:

    解决方案写在你的帖子中。

    要解决此问题,请减少机器上的负载或调整 minFreeMemoryPercentageToActivateService 的值 serviceHostingEnvironment 配置元素。

    最简单的方法就是把它添加到你的 web.config 中

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

    阅读更多关于serviceHostingEnvironmenthere的信息。

    无论如何@Mr Grok 如何正确指出这表明您的机器没有足够的物理内存,您应该弄清楚为什么会发生这种情况。这可能是一个严重的问题。

    【讨论】:

    • 虽然这将是最简单的,但值得注意的是,如果您的服务器资源不足,则此错误可能表明您的计算机上没有足够的物理内存,因此您可以关闭遇到更大的问题。检查资源监视器/任务管理器以查看正在使用的内存量是非常值得的。
    • 想知道为什么不是 ~2% 而不是 0%?使用 0% 时,它不是将服务器上的每个进程(可能是关键进程)都置于分配失败(可能未处理)的危险中吗?哦,“可用内存”不包括虚拟(查看任务管理器显示 free=0 和 commit = 8/13)?谁能确认一下?
    【解决方案2】:

    我遇到了这个问题。结果是 SQL 服务器使用了我可用的 32 GB 中的超过 29 GB。

    如果您有 SQL Server,请检查您的 SQL Server。 MS SQL Sever 旨在占用您允许的尽可能多的可用空间。您可以在 SQL Server 的属性选项卡中的最大服务器内存框中对此进行限制。

    【讨论】:

      【解决方案3】:

      我在 web.config 中将 serviceHostingEnvironment 属性添加到 0。

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

      这是我发现的最简单的方法。

      【讨论】:

        【解决方案4】:

        好吧,我遇到了同样的问题,我正在寻找解决方案。大多数博客都建议使用相同的解决方案在 web.config 中添加“serviceHostingEnvironment”属性,这是一项有风险的工作,因为添加属性会影响整个 IIS 及其托管解决方案,并最终会重新启动 IIS。

        由于错误消息与“内存存储问题”有关,我们被要求减少服务器上的负载,所以我所做的只是通过服务管理器重新启动 SQL Server (MSSQLSERVER) 服务,一切都恢复正常,我得到了摆脱内存问题。

        Window + R > services.msc > 在突出显示的服务下方重新启动

        【讨论】:

          【解决方案5】:

          web.config 对我有用,但 SQL Server 内存也是一个需要解决的问题。

          我能够在不重新启动 MSSQL 服务器进程的情况下解决 sql server 内存问题,只需将服务器属性 memory Maximum server memory 降低到一个较低的值。默认为有效无限制。

          无需重新启动 MS SQL 服务,进程就会自动开始将内存占用减少到配置的值。

          【讨论】:

            【解决方案6】:

            我尝试在 web.config 文件中设置 minFreeMemoryPercentageToActivateService="0" ,但这在我的情况下仍然没有解决。 我正在使用 VMWare,它的执行速度非常慢,因为我有太多快照!!我删除了旧的,清理了一些磁盘空间并重新启动了服务器,这样做解决了所有错误。

            我是 VMWare 和 SharePoint 的新手,我想我可以在这里分享我的经验!

            【讨论】:

              【解决方案7】:

              将此添加到您的 machine.config 中的 system.serviceModel 部分下,这将为所有站点设置它:

              <serviceHostingEnvironment minFreeMemoryPercentageToActivateService="0" />
              

              您需要管理员权限才能编辑此文件。

              请参阅this answer,了解如何找到 machine.config。

              您可以在添加此设置之前检查是否有任何进程使用了​​过多的内存。但是对我来说,默认设置弊大于利,因为有很多“备用”内存正在使用,系统可以在需要时弹出,所以系统并没有真正的内存不足。

              【讨论】:

                【解决方案8】:

                您需要使用 IISReset 命令行实用程序重新启动 IIS 从“开始”菜单中,单击“运行”。

                在“打开”框中,键入 cmd,然后单击“确定”。

                在命令提示符下,键入:iisreset /noforce

                IIS 尝试在重新启动之前停止所有服务。 IISReset 命令行实用程序最多等待一分钟以停止所有服务。

                【讨论】:

                  猜你喜欢
                  • 2016-01-28
                  • 1970-01-01
                  • 1970-01-01
                  • 2010-12-20
                  • 1970-01-01
                  • 2011-03-20
                  • 1970-01-01
                  • 1970-01-01
                  • 1970-01-01
                  相关资源
                  最近更新 更多