问题描述
.Net应用程序部署在App Service for Windows环境中,已经根据需求把Platform的位数由32 bit 修改位 64 bit。 但是应用程序在运行一段时间后,一直抛出Out Of Memory异常。
System.OutOfMemoryException: at System.GC.AllocateNewArray
同时,查看App Service 内存占用指标,才不到2GB。
问题解答
在App Service中,处理要修改Windows 平台为 64外,还需要额外安装 asp.net core runtime x64 version。
默认情况下,x64 dotnet runtime 不会安装在应用服务上。由于在 x64 中运行了应用服务,因此它将请求代理到一个 32 位 dotnet 进程,当请求的内存 >100MB,进程会引发 OutOfMemoryException
解决办法是在App Service门户 Extensions 页面中,安装.NET x runtime x64 版本。安装好扩展插件后,需要重启应用。
- Web App --> Extensions -->"Add" --> 使用 "ASP.NET Core " 关键字过滤
之后,监控App Service 指标,证明内存使用可以达到预期。
参考资料
ASP.NET 6 - Out of Memory Exception on App Service :https://github.com/dotnet/runtime/issues/71014
Cause
x64 dotnet runtime is not installed on the app service by default. Since we had the app service running in x64, it was proxying the request to a 32 bit dotnet process which was throwing an OutOfMemoryException with requests >100MB. It worked on the IaaS servers because we had the x64 runtime installed.Resolution
Installed the ‘ASP.NET Core 5.0 (x64) Runtime’ extension to the app service and restarted the app service.
标签:Service,App,x64,2GB,dotnet,NET,runtime From: https://www.cnblogs.com/lulight/p/18546667