ASP.NET Core Web API返回类,导致内存泄漏?
根据要求,创建了一个ASP.NET Core Web API,以转化为JSON或XML输出的方式。
其中一种典型的返回方法具有诸如
[Microsoft.AspNetCore.Mvc.HttpGet("SomeCommand/{id?}")]
public ActionResult<Response.Command> SomeCommand(int id)
{
// ...
// Some minimal logic nothing that can cause memory strains
// A class Response containing sub classes as placeholders for values
// Each nested class within has a constructor to set its values
return new Response.SomeCommand(x)
}
ASP.NET之类的语法,确实将类正确转换为JSON输出或XML输出没有问题。
但是,它慢慢地使用了越来越多的内存。
有更好的方法吗?
还是迫使垃圾收集者释放这些课程的方法?
还是我不必担心,这是正常的GC(时间很长的时间?)。
(如今,它看起来像是内存泄漏)。
Upon request, an ASP.NET Core Web API was created, in such a way that it translates to json or XML output.
A typical return method in it has a syntax like
[Microsoft.AspNetCore.Mvc.HttpGet("SomeCommand/{id?}")]
public ActionResult<Response.Command> SomeCommand(int id)
{
// ...
// Some minimal logic nothing that can cause memory strains
// A class Response containing sub classes as placeholders for values
// Each nested class within has a constructor to set its values
return new Response.SomeCommand(x)
}
ASP.NET does correctly convert the class to a JSON output or XML output no problems there.
However, it slowly uses more and more memory it seems.
Is there a better way to do this?
Or a way to force the garbage collector to free up those classes?
Or shouldn't I worry about it, it's normal GC takes (a long?) time.
(as now it looks like a memory leak).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论