首页 > 其他分享 >【Azure App Service】在App Service中调用Stroage SDK上传文件时遇见 System.OutOfMemoryException

【Azure App Service】在App Service中调用Stroage SDK上传文件时遇见 System.OutOfMemoryException

时间:2024-11-16 11:32:19浏览次数:1  
标签:Service ResourceInvoker App System Microsoft Mvc AspNetCore

问题描述

部署.NET 应用到App Service中,应用中调用Storage Account的SDK上传文件到Blob中。只是比较高频率在UploadAsync方法中遇见:OutOfMemoryException

异常信息

ERROR Microsoft.AspNetCore.Server.Kestrel.? [?] - MESSAGE: Connection id "0HN3UB91BK6BS", Request id "0HN3UB91BK6BS:00000585": An unhandled exception was thrown by the application.

 System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

   at System.GC.AllocateNewArray(IntPtr typeHandle, Int32 length, GC_ALLOC_FLAGS flags)

   at System.GC.<AllocateUninitializedArray>g__AllocateNewUninitializedArray|66_0[T](Int32 length, Boolean pinned)

   at System.Buffers.TlsOverPerCoreLockedStacksArrayPool`1.Rent(Int32 minimumLength)

   at Microsoft.AspNetCore.WebUtilities.HttpResponseStreamWriter..ctor(Stream stream, Encoding encoding, Int32 bufferSize, ArrayPool`1 bytePool, ArrayPool`1 charPool)

   at Microsoft.AspNetCore.Mvc.Infrastructure.MemoryPoolHttpResponseStreamWriterFactory.CreateWriter(Stream stream, Encoding encoding)

   at Microsoft.AspNetCore.Mvc.NewtonsoftJson.NewtonsoftJsonResultExecutor.ExecuteAsync(ActionContext context, JsonResult result)

   at Microsoft.AspNetCore.Mvc.NewtonsoftJson.NewtonsoftJsonResultExecutor.ExecuteAsync(ActionContext context, JsonResult result)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()

--- End of stack trace from previous location ---

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)

   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)

   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)

   at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)

   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)

   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)

   at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

 

 

问题解答

从Exception中的Stack Trace上看Out Of Memory发生在GC Allocate New Array,  是在HTTP Process Requests/Response时,需要申请内存遇见内存不足异常。 而异常中信息不充足无法定位。但从App Service的角度,可以考虑修改App Service Platform为64bit (App Service for windows 默认为32bit)。如修改后,依旧出现OutOfMemory异常,则需要考虑收集w3wp.exe 或 dotnet.exe 进程的DUMP文件进行深入分析。

 

I see the message "Worker Process requested recycle due to 'Percent Memory' limit." How do I address this issue?

The maximum available amount of memory for a 32-bit process (even on a 64-bit operating system) is 2 GB. By default, the worker process is set to 32-bit in App Service (for compatibility with legacy web applications).

Consider switching to 64-bit processes so you can take advantage of the additional memory available in your Web Worker role. This action triggers a web app restart, so schedule accordingly.

Also note that a 64-bit environment requires a Basic or Standard service plan. Free and Shared plans always run in a 32-bit environment.

For more information, see Configure web apps in App Service.

 

analyzing the memory dump

This article provides guidance about Microsoft Azure App Service debugging features for capturing memory dumps. The capture method that you use is dictated by the scenario in which you capture a memory dump for troubleshooting a performance or availability issue. For example, capturing a memory dump is different for a process that's experiencing excessive memory consumption than for a process that's throwing exceptions or responding slowly. The process in this context is the Internet Information Services (IIS) worker process (W3WP, which runs as w3wp.exe).

 

 

参考资料

Capture memory dumps on the Azure App Service platform : https://learn.microsoft.com/en-us/troubleshoot/azure/app-service/capture-memory-dumps-app-service#next-steps-analyzing-the-memory-dump

Application performance FAQs for Web Apps in Azure : https://learn.microsoft.com/en-us/troubleshoot/azure/app-service/web-apps-performance-faqs

 

标签:Service,ResourceInvoker,App,System,Microsoft,Mvc,AspNetCore
From: https://www.cnblogs.com/lulight/p/18549189

相关文章

  • 短视频app搭建,了解Java基本数据类型
    短视频app搭建,了解Java基本数据类型Java条件语句if…else一个if语句包含一个布尔表达式和一条或多条语句。//如果只有一条语句可以不用{}if(--)a=0;//多条语句需要{}if(--){a=0;b=0;}//if()的()里面填条件 if…else语句if语句后面可以跟else语句,当if......
  • 基于SpringBoot+Vue+uniapp的中小型医院网站的详细设计和实现(源码+lw+部署文档+讲解
    文章目录前言详细视频演示具体实现截图技术栈后端框架SpringBoot前端框架Vue持久层框架MyBaitsPlus系统测试系统测试目的系统功能测试系统测试结论为什么选择我代码参考数据库参考源码获取前言......
  • Web端、App端的日志查看
    开发和测试过程中,日志是定位问题的重要工具之一。无论是Web端还是App端,日志的作用如同医生的诊断报告,可以帮我们快速找到问题的根源。那么,如何高效查看并分析这些日志呢?面对Web端和App端的不同特点,日志查看有哪些工具和方法?我们如何才能快速、准确地提取有用信息?有哪些最佳实......
  • 【Azure App Service】在App Service上关于OpenSSH的CVE2024-6387漏洞解答
    问题描述当OpenSSH的版本低于9.8p1,有漏洞风险: Asecurityregression(CVE-2006-5051)wasdiscoveredinOpenSSH'sserver(sshd).Thereisaraceconditionwhichcanleadsshdtohandlesomesignalsinanunsafemanner.Anunauthenticated,remoteattackerma......
  • Android15音频进阶之input调节CarAudioService音量过程(九十四)
    简介:CSDN博客专家、《Android系统多媒体进阶实战》一书作者新书发布:《Android系统多媒体进阶实战》......
  • 【SpringBoot每日学习 - 第二天】SpringApplication 启动类:方法篇一
    SpringApplication类是SpringBoot应用程序的核心类之一,负责启动和初始化整个SpringBoot应用。通过调用SpringApplication.run()方法,SpringBoot会启动嵌入式的Web服务器(如Tomcat)并创建Spring容器。SpringApplication类具有一系列方法和配置项,允许开发者自定......
  • 【SpringBoot每日学习 - 第一天】SpringApplication 启动类:属性篇
    SpringApplication类是SpringBoot应用启动的核心类之一,包含了大量的属性,控制着应用启动的各个方面。这些属性涵盖了从配置环境、应用上下文类型、Banner显示、启动日志、事件监听等多个方面。以下是SpringApplication类中重要属性的详细说明及其用途:静态属性DEFAUL......
  • 效率工具:4款电脑桌面必备办公神器APP!
    今天来给大家分享4款电脑桌面必备的办公神器APP,真的可以大大提高我们的工作效率!一、PixPin这是一款超赞的截图和标注工具。它的截图功能非常强大,可以自由选择截图区域。截完图后,重点来了!它有丰富的标注工具,比如箭头、文字、马赛克等。还可以把截图贴在其他窗口之上,供随时查看......
  • 加油APP开发,打造一站式加油卡管理与服务
    随着社会的发展,汽车的需求量不断上升,车辆加油成为了生活必需品。这也直接推动了加油APP的发展,为大众带来便捷的充值加油渠道,还能够让车主享受优惠加油,节省日常开支。加油充值APP是一个让用户可以在线充值、加油、购物的应用程序,用户可以通过手机一键查询汽车加油的相关情况,在......
  • CSAPP 并发编程
    frompixiv前置知识进程逻辑控制流(简称逻辑流)CSAPPP508:一系列的程序计数器PC的值唯一地对应于包含在程序的可执目标文件中的指令或包含在运行时动态链接到程序的共享对象指令。这个PC值的序列叫逻辑控制流一个逻辑流的执行在时间上与另一个流重叠,称为并发流,这两个流被......