【问题标题】:App Insights memory leak in background tasks后台任务中的 App Insights 内存泄漏
【发布时间】:2021-07-09 03:58:12
【问题描述】:

我在 .NET web api(.net 4.8 框架)中使用 Simple Injector DI,并且在遥测客户端周围有一个包装类(我自己的实现)。

public class MyAppInsights : IMyAppInsights
{
private static TelemetryClient telemetry;
public MyAppInsights ()
{
if (telemetry == null)
{
telemetry = new TelemetryClient();
}
}
//other interface method implementations
}

简单的注入器启动配置如下

container.Register(Lifestyle.Singleton);

我注意到许多 Httpwebrequest 对象(应用程序洞察)被添加到内存中,并且没有为长时间运行的后台任务释放。此问题仅在最近执行导致内存不足异常的长时间运行的后台任务后才出现。

任何关于如何减少/堵塞内存泄漏/消耗的指针将不胜感激

【问题讨论】:

    标签: asp.net-web-api memory-leaks out-of-memory background-process appinsights


    【解决方案1】:

    您可以尝试删除 Lifestyle.Singleton 以查看是否仍有内存泄漏。 例如,还要检查网站。

    https://docs.simpleinjector.org/en/latest/quickstart.html

    【讨论】:

    • 我也试过了,但没有任何区别。
    猜你喜欢
    • 2012-07-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多