正文

asp.net core服务限制堆内存大小的操作方法(asp.net core task)快来看

文章摘要

当前堆内存大小逐渐增加,从102.0029 MB上升到902.0498 MB,最终导致`TestController.testMemory()`方法执行过程中抛出`System.OutOfMemoryException`,表明程序因堆内存溢出而崩溃。错误信息显示异常发生在`TestController.cs`的第49行,提示堆内存不足无法继续运行。这表明程序在内存管理上存在问题,可能需要增加内存配置或优化代码以避免溢出。

当前堆内存大小 — 102.0029296875 MB 当前堆内存大小 — 202.013671875 MB 当前堆内存大小 — 302.0166015625 MB 当前堆内存大小 — 402.0126953125 MB 当前堆内存大小 — 502.0166015625 MB 当前堆内存大小 — 602.02734375 MB 当前堆内存大小 — 702.044921875 MB 当前堆内存大小 — 802.046875 MB 当前堆内存大小 — 902.0498046875 MB info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2] Executed action office_conver_server.Controllers.TestController.testMemory (office-conver-server) in 5924.7612ms info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1] Executed endpoint ‘office_conver_server.Controllers.TestController.testMemory (office-conver-server)’ fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1] An unhandled exception has occurred while executing the request. System.OutOfMemoryException: Exception of type ‘System.OutOfMemoryException’ was thrown. at office_conver_server.Controllers.TestController.testMemory() in D:\BaiduSyncdisk\项目目录\ItemProjects\dotnet\office-conver-server\Controllers\TestController.cs:line 49 at Microsoft.Extensions.Internal.ObjectMethodExecutor.<>c__DisplayClass33_0.<WrapVoidMethod>b__0(Object target, Object[] parameters) at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.VoidResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Obje ct[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync() at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync() — End of stack trace from previous location — at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() — 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 sta te, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)