spa*_*pan 4 .net-core asp.net-core
我有一个应用程序,我怀疑其中存在内存泄漏。不仅在堆中,而且在我看来,对于向我的应用程序发出的每个请求,整个工作集都在增长。我正在尝试根据这些说明对其进行调试,但我很难解释我所看到的内容。我正在使用该dotnet-dump工具来分析转储。
DocumentClient如果我解释正确的话,总共有 618 个实例。当然,这会增加字符串、字节数组等中的大量数据。
Statistics:
MT Count TotalSize Class Name
00007f853c355110 618 187872 Microsoft.Azure.Cosmos.DocumentClient
Run Code Online (Sandbox Code Playgroud)
以下是取自文档客户端方法表的单个引用的片段。请参阅pastebin 以获取完整参考。它持续了 1200 多行,其中大部分是TimerQueueTimer参考文献。
00007F85AF2F10D8 (strong handle)
-> 00007F84C80FBAD8 System.Object[]
-> 00007F84C80FBB00 System.Threading.ThreadLocal`1+LinkedSlotVolatile[[System.Collections.Concurrent.ConcurrentBag`1+WorkStealingQueue[[System.IDisposable, System.Private.CoreLib]], System.Collections.Concurrent]][]
-> 00007F84C80FBB40 System.Threading.ThreadLocal`1+LinkedSlot[[System.Collections.Concurrent.ConcurrentBag`1+WorkStealingQueue[[System.IDisposable, System.Private.CoreLib]], System.Collections.Concurrent]]
-> 00007F84C80FBB70 System.Collections.Concurrent.ConcurrentBag`1+WorkStealingQueue[[System.IDisposable, System.Private.CoreLib]]
-> 00007F84C80FBBB0 System.IDisposable[]
-> 00007F84C80FBA90 System.Diagnostics.DiagnosticListener+DiagnosticSubscription
-> 00007F84C80FAF30 Microsoft.ApplicationInsights.AspNetCore.DiagnosticListeners.HostingDiagnosticListener
-> 00007F84C80EB450 Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration
-> 00007F84C80D5688 Microsoft.ApplicationInsights.Extensibility.Implementation.ApplicationId.ApplicationInsightsApplicationIdProvider
-> 00007F84C80D5A60 Microsoft.ApplicationInsights.Extensibility.Implementation.ApplicationId.ProfileServiceWrapper
-> 00007F84C80D5A88 System.Net.Http.HttpClient
-> 00007F84C80D5AD0 System.Net.Http.HttpClientHandler
-> 00007F84C80D5B00 System.Net.Http.SocketsHttpHandler
-> 00007F84D80D1018 System.Net.Http.RedirectHandler
-> 00007F84D80D1000 System.Net.Http.HttpConnectionHandler
-> 00007F84D80D0D38 System.Net.Http.HttpConnectionPoolManager
-> 00007F84D80D0F70 System.Threading.Timer
-> 00007F84D80D0FE8 System.Threading.TimerHolder
-> 00007F84D80D0F88 System.Threading.TimerQueueTimer
-> 00007F84C80533A0 System.Threading.TimerQueue
-> 00007F84D910F3C0 System.Threading.TimerQueueTimer
-> 00007F84D910EE58 System.Threading.TimerQueueTimer
-> 00007F84D910A680 System.Threading.TimerQueueTimer
Run Code Online (Sandbox Code Playgroud)
我是否存在 Application Insights 或 Cosmos 内存泄漏?为什么有这么多TimerQueueTimer参考文献?
小智 5
await Task.DelayTimerQueueTimer在每次调用时创建新的。
许多 TimerQueueTimer 表示有人await Task.Delay()在循环中使用,而不是使用 simple new Timer()。
-> Microsoft.Azure.Cosmos.Routing.GlobalEndpointManager+<StartRefreshLocationTimer>d__25
-> Microsoft.Azure.Cosmos.Routing.GlobalEndpointManager
看起来 Microsoft.Azure.Cosmos 的 GlobalEndpointManager每次在 GlobalEndpointManager.cs 类的 StartRefreshLocationTimer 方法中抛出异常时都使用 await Task.Delay
你可以在这里尝试一些事情:
我猜这应该有助于记录异常:(
DefaultTrace.TraceSource.Listeners.Add(new System.Diagnostics.ConsoleTraceListener())
检查示例)
2) 确保ShouldRefreshEndpoints返回 false,如果您的应用没问题 :)
| 归档时间: |
|
| 查看次数: |
429 次 |
| 最近记录: |