简体   繁体   English

如何在 Azure 应用服务上运行的 ASP.NET Framework 应用中禁用服务器 GC

[英]How to disable Server GC in ASP.NET Framework App running on Azure App Service

I'm doing some high density hosting of ASP.NET MVC 5 / WCF apps on Azure App Service and the idle apps are using 600~1000MB of memory each which is quite a lot, given that a memory dump reveals that the GC heap is only about ~40MB full.我正在 Azure 应用服务上对 ASP.NET MVC 5/WCF 应用程序进行一些高密度托管,而空闲应用程序每个使用 600~1000MB 的内存,这相当多,因为内存转储显示 GC 堆是只有大约 40MB 满。 I suspect this is due to server GC so i tried disabling it by following https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/gcserver-element and adding我怀疑这是由于服务器 GC,所以我尝试通过遵循https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/gcserver-element并添加来禁用它

<gcServer enabled="false" />

to my web.config, but this does not appear to have any effect as到我的 web.config,但这似乎没有任何影响

GCSettings.IsServerGC

is still returning true.仍然返回true。 What am i missing here?我在这里缺少什么?

EDIT:编辑:

Using normal IIS it can be done using https://weblogs.asp.net/owscott/setting-an-aspnet-config-file-per-application-pool but in Azure App Service, you lack the permissions to do this.使用普通的 IIS 可以使用https://weblogs.asp.net/owscott/setting-an-aspnet-config-file-per-application-pool来完成,但在 Azure 应用服务中,你缺乏执行此操作的权限。

Ok, first of all, it seems like you might have to manually debug the memory usage of components using GC.Collect(): https://docs.microsoft.com/en-us/dotnet/api/system.gc.collect?view=netcore-3.1好的,首先,您似乎必须使用 GC.Collect() 手动调试组件的内存使用情况: https ://docs.microsoft.com/en-us/dotnet/api/system.gc.collect ?view=netcore-3.1

This way you might be able to pinpoint a specific part of the code that either causes a memory leak due to bad garbage collection, or parts that are using certain third-party libraries.通过这种方式,您可能能够查明代码的特定部分,这些部分要么由于垃圾回收不良而导致内存泄漏,要么使用某些第三方库的部分。

Once you are done with this quite tedious part, then depending on what you think is causing the problem, you should consider either using a manual disposal of the code block utilizing (using var item = new NameOfClass()) or even trying ti implement IDispose on the classes that are causing it: https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-dispose .一旦你完成了这个相当乏味的部分,然后根据你认为导致问题的原因,你应该考虑使用手动处理代码块(using var item = new NameOfClass())或者甚至尝试实现IDispose关于导致它的类: https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/implementing-dispose

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从托管在 Azure 应用服务中的 .Net Framework Asp.Net 应用程序访问 Azure KeyValut? - How do I access an Azure KeyValut from an .Net Framework Asp.Net application hosted in an Azure App Service? ASP.NET Core应用到Azure应用服务上的Linux - ASP.NET Core app to Linux on Azure App Service https在Z1848E7322214CCE460F9B24F9B24F5E72Z CORE 3.1 Z2567A.AS SERSER 3.1 - force https on an asp.net core 3.1 web app running as a service on a windows server 2008 rs server 如何诊断部署到 Azure 应用服务的示例 ASP.NET/Cosmos Web 应用程序? - How to Diagnose sample ASP.NET/Cosmos Web App deployed to Azure App Service? 如何为 ASP.NET Core 应用程序配置 Azure 应用服务日志记录提供程序? - How to configure Azure App Service logging provider for an ASP.NET Core app? 如何将 Blazor Web 程序集与 ASP.NET 核心托管和身份验证应用程序发布到 ZCF04A02E37B774FC3917A 服务? - How to publish Blazor Web assembly with ASP.NET core hosting and identity auth app to azure App Service? ASP.net 核心 docker https on Azure 应用服务容器 - ASP.net core docker https on Azure App Service Containers ASP.NET Core 对 Azure 应用服务的 HTTP 请求缓慢 - ASP.NET Core slow HTTP requests to Azure App Service Azure Service Fabric中的ASP.NET Core应用程序中的WebpackDevMiddleware - WebpackDevMiddleware in ASP.NET Core app in Azure Service Fabric 将ASP.NET Core部署到Azure Web App服务错误 - Deploy ASP.NET Core to Azure Web App Service Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM