asp.net core服务限制堆内存大小的操作方法

  当前堆内存大小 -- 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项目目录ItemProjectsdotnetoffice-conver-serverControllersTestController.cs:line 49

  at Microsoft.Extensions.Internal.ObjectMethodExecutor.<>c__DisplayClass33_0.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.g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object sta

  te, Boolean isCompleted)

  at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)

  at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker)

  at Microsoft.AspNetCore.Routing.EndpointMiddleware.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)