- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在通过使用 Windbg 分析内存转储来调查运行高达 10GB 内存的 Web 应用。
这是 !dumpheap -stat 输出的底部:
00007ff9545df5d0 166523 13321840 System.Runtime.Caching.MemoryCache
00007ff9545df4a0 166523 14654024 System.Runtime.Caching.CacheMemoryMonitor
00007ff9545de990 166523 14654024 System.Runtime.Caching.SRef[]
00007ff9545dcef0 166523 14654024 System.Runtime.Caching.GCHandleRef`1[[System.Runtime.Caching.MemoryCacheStore, System.Runtime.Caching]][]
00007ff9545dfb28 166523 19982760 System.Runtime.Caching.MemoryCacheStatistics
00007ff956778510 333059 21315680 System.Int64[]
00007ff95679c988 41597 31250111 System.Byte[]
00007ff9545e08c8 1332184 31972416 System.Runtime.Caching.MemoryCacheEqualityComparer
00007ff9545dfe48 1332184 31972416 System.Runtime.Caching.SRef
00007ff956780ff0 1332200 31972800 System.SizedReference
00007ff956724620 1498777 35970648 System.Threading.TimerHolder
00007ff95677fb30 1536170 36868080 System.Runtime.Remoting.Messaging.CallContextSecurityData
00007ff956796f28 1606960 38567040 System.Object
00007ff9545df810 1332184 42629888 System.Runtime.Caching.GCHandleRef`1[[System.Runtime.Caching.MemoryCacheStore, System.Runtime.Caching]]
00007ff9545dda38 1332184 42629888 System.Runtime.Caching.UsageBucket[]
00007ff9567ae930 1332268 42632576 Microsoft.Win32.SafeHandles.SafeWaitHandle
00007ff9545df968 1498707 47958624 System.Runtime.Caching.GCHandleRef`1[[System.Threading.Timer, mscorlib]]
00007ff9567adbf8 1498777 47960864 System.Threading.Timer
00007ff9545dff50 1332184 53287360 System.Runtime.Caching.CacheUsage
00007ff94986ead8 1536137 61445480 System.Web.Hosting.AspNetHostExecutionContextManager+AspNetHostExecutionContext
00007ff9567a2838 1332210 63946080 System.Threading.ManualResetEvent
00007ff956796948 293525 66384986 System.String
00007ff9545dfef0 1332184 74602304 System.Runtime.Caching.CacheExpires
00007ff9567add20 1498760 95920640 System.Threading.TimerCallback
00007ff9545dfa90 1332184 106574720 System.Runtime.Caching.MemoryCacheStore
00007ff95679b3b0 1333289 106663120 System.Collections.Hashtable
00007ff95678f138 1536171 110604312 System.Runtime.Remoting.Messaging.LogicalCallContext
00007ff9545dffb0 1332184 127889664 System.Runtime.Caching.UsageBucket
00007ff95679d1e0 1333292 128664768 System.Collections.Hashtable+bucket[]
00007ff9567245c0 1498777 131892376 System.Threading.TimerQueueTimer
00007ff9567aec48 1536255 135190440 System.Threading.ExecutionContext
00007ff9545dcf78 1332184 351696576 System.Runtime.Caching.ExpiresBucket[]
000000f82c79d9f0 473339 385303992 Free
00007ff956799220 40309535 1617342672 System.Int32[]
00007ff9545e0468 39965520 3836689920 System.Runtime.Caching.ExpiresBucket
所以 System.Runtime.Caching.ExpiresBucket
有将近 4000 万个实例,总共使用了将近 4gb 的内存。 System.Runtime.Caching
类在最常见的违规者中出现了很多。
我取了一个 System.Runtime.Caching.ExpiresBucket
类的随机实例,并对其执行了 !gcroot。生成 1 个线程需要很长时间(可能需要 30 分钟)……可能还有更多线程,但此时我中断了操作。
引用链超过 150 万行!但我可以在这里展示重要的部分:
0:000> !gcroot 000000f82dd4bc28
Thread 1964:
000000fcbdbce6a0 00007ff8f9bbe388 Microsoft.AspNet.SignalR.SqlServer.ObservableDbOperation.ExecuteReaderWithUpdates(System.Action`2<System.Data.IDataRecord,Microsoft.AspNet.SignalR.SqlServer.DbOperation>)
rbp-58: 000000fcbdbce6e8
-> 000000fa2d1f26a0 Microsoft.AspNet.SignalR.SqlServer.ObservableDbOperation+<>c__DisplayClass1e
-> 000000fa2d1f2110 Microsoft.AspNet.SignalR.SqlServer.ObservableDbOperation
-> 000000fa2d1f24d0 System.Action
-> 000000fa2d1f24a8 System.Object[]
-> 000000fa2d1f2468 System.Action
-> 000000fa2d1f1008 Microsoft.AspNet.SignalR.SqlServer.SqlReceiver
-> 000000fa2d1f1330 System.Action
-> 000000fa2d1f1308 System.Object[]
-> 000000fa2d1f12c8 System.Action
-> 000000fa2d1efb70 Microsoft.AspNet.SignalR.SqlServer.SqlStream
-> 000000fa2d1f1528 System.Action
-> 000000fa2d1f1500 System.Object[]
-> 000000fa2d1f14c0 System.Action
-> 000000fa2d1efb20 Microsoft.AspNet.SignalR.SqlServer.SqlMessageBus+<>c__DisplayClass3
-> 000000f92d0b84e0 Microsoft.AspNet.SignalR.SqlServer.SqlMessageBus
-> 000000f92d0b9568 System.Threading.Timer
-> 000000f92d0b96d8 System.Threading.TimerHolder
-> 000000f92d0b95a0 System.Threading.TimerQueueTimer
[... about 100 lines of the same TimerQueueTimer line above, but different memory addresses each time]
-> 000000f92cf1be68 System.Threading.TimerQueueTimer
-> 000000f92cf1be08 System.Threading.TimerCallback
-> 000000f92cf1bb48 System.Web.RequestTimeoutManager
-> 000000f92cf1bb80 System.Web.Util.DoubleLinkList[]
-> 000000f92cf1bc00 System.Web.Util.DoubleLinkList
-> 000000fb61323860 System.Web.RequestTimeoutManager+RequestTimeoutEntry
-> 000000fb6131fd38 System.Web.HttpContext
-> 000000fbe682a480 ASP.global_asax
-> 000000fbe682ac00 System.Web.HttpModuleCollection
-> 000000fbe682ac60 System.Collections.ArrayList
-> 000000fbe682b598 System.Object[]
-> 000000fbe682b018 System.Collections.Specialized.NameObjectCollectionBase+NameObjectEntry
-> 000000fbe682b000 System.Web.Routing.UrlRoutingModule
-> 000000faacec1f40 System.Web.Routing.RouteCollection
-> 000000faacec2030 System.Collections.Generic.List`1[[System.Web.Routing.RouteBase, System.Web]]
-> 000000fa2cfe4d80 System.Web.Routing.RouteBase[]
-> 000000f9acf14cd8 System.Web.Http.WebHost.Routing.HttpWebRoute
-> 000000f9acf149f8 System.Web.Http.Routing.RouteCollectionRoute
-> 000000f9acf1f4f0 System.Web.Http.Routing.SubRouteCollection
-> 000000f9acf1f510 System.Collections.Generic.List`1[[System.Web.Http.Routing.IHttpRoute, System.Web.Http]]
-> 000000fa2cf8f310 System.Web.Http.Routing.IHttpRoute[]
-> 000000fa2ceff770 System.Web.Http.Routing.HttpRoute
-> 000000fa2ceff678 System.Web.Http.Routing.HttpRouteValueDictionary
-> 000000fa2ceff6f0 System.Collections.Generic.Dictionary`2+Entry[[System.String, mscorlib],[System.Object, mscorlib]][]
-> 000000fa2cef9e78 System.Web.Http.Controllers.HttpActionDescriptor[]
-> 000000fa2cef7898 System.Web.Http.Controllers.ReflectedHttpActionDescriptor
-> 000000f9aced4608 System.Web.Http.HttpConfiguration
-> 000000f9aced4db0 System.Net.Http.Formatting.MediaTypeFormatterCollection
-> 000000f9aced6f40 System.Collections.Generic.List`1[[System.Net.Http.Formatting.MediaTypeFormatter, System.Net.Http.Formatting]]
-> 000000f9aced6f80 System.Net.Http.Formatting.MediaTypeFormatter[]
-> 000000f9aced4df8 System.Net.Http.Formatting.JsonMediaTypeFormatter
-> 000000f9acf1f448 System.Web.Http.Validation.ModelValidationRequiredMemberSelector
-> 000000f9acf1f468 System.Collections.Generic.List`1[[System.Web.Http.Validation.ModelValidatorProvider, System.Web.Http]]
-> 000000f9acf1f490 System.Web.Http.Validation.ModelValidatorProvider[]
-> 000000f9acf1db40 Ninject.Web.WebApi.Validation.NinjectDefaultModelValidatorProvider
-> 000000faaceca438 Ninject.StandardKernel
-> 000000faaceca498 Ninject.Components.ComponentContainer
-> 000000faaceca538 System.Collections.Generic.Dictionary`2[[System.Type, mscorlib],[Ninject.Components.INinjectComponent, Ninject]]
-> 000000f9acece000 System.Collections.Generic.Dictionary`2+Entry[[System.Type, mscorlib],[Ninject.Components.INinjectComponent, Ninject]][]
-> 000000f9acecdac8 Ninject.Activation.Caching.GarbageCollectionCachePruner
-> 000000f9acecdcb8 System.Threading.Timer
-> 000000f9acecdd30 System.Threading.TimerHolder
-> 000000f9acecdcd8 System.Threading.TimerQueueTimer
[... just under 1.5 million lines of the same TimerQueueTimer line above, but different memory addresses each time]
-> 000000f82dd4c028 System.Threading.TimerQueueTimer
-> 000000f82dd4bfc8 System.Threading.TimerCallback
-> 000000f82dd4ada0 System.Runtime.Caching.CacheExpires
-> 000000f82dd4add8 System.Runtime.Caching.ExpiresBucket[]
-> 000000f82dd4bc28 System.Runtime.Caching.ExpiresBucket
在 000000faaceca438 Ninject.StandardKernel
上运行 !objsize 似乎要花很长时间,这意味着它引用了非常多的对象,可能所有 4000 万个 System.Runtime.Caching.ExpiresBucket
对象...
是什么导致泄漏?我应该如何识别有问题的类或代码?在 gcroot 输出中没有引用我们自己的任何代码,这是由于我们正在使用的已安装库之一中的错误吗?它在 Ninject 中吗?我们使用的是 v3.2.2(我知道不是最新的)
最佳答案
作为答案发布,因为评论太长了:
在我看来,Ninject 正在跟踪大量范围对象。 AFAIR 这就是 GarbageCollectionPruner
的用途。作用域对象是用 .InScope(...this object here...)
或一些重载如 InRequestScope()
定义的对象。GarbageCollectionPruner
有一个计时器,它会定期检查范围是否仍然“有效”。如果它不再存在(收集垃圾),它将处理并忘记与该范围关联的所有对象。
除非 ninject 中没有错误,否则这意味着您的应用程序会在短时间内创建大量作用域或者它们没有被正确清理(意思是:您或其他第 3 层的问题党代码)。
顺便说一句,如果作用域对象实现了INotifyWhenDisposed
(ninject 接口(interface)),那么周期性的IsAlive
检查就没有必要了,而且还提供了“确定性”处置的好处,即就在范围结束时,范围内的对象也会被释放。否则这取决于 Ninject 中的 GC 和计时器......
关于memory-leaks - Ninject 中的内存泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47206497/
我的应用有时会抛出奇怪的日志,例如: :通知名称“com.apple.iapd.notify.extendedMode”已被注册 40 次 - 这可能是泄漏:通知名称“com.apple.iapd.n
我在 dotcloud 上使用 redis 内存存储,但尽管 key 已过期,但它的 used_memory 再也不会下降。从 redis-cli 使用 flushdb 或 flushall 不会导致
所以我一直在寻找这个问题的解决方案有一段时间了。我编写了一个程序来从两个单独的文本文件中获取数据,对其进行解析,然后输出到另一个文本文件和一个 ARFF 文件以供 Weka 分析。我遇到的问题是我编写
随着我继续学习 Rust,我正在从事一个涉及广泛使用谓词函数的项目。我决定用 Rust 闭包实现这些谓词,例如: type Predicate = Box bool> . 我的程序使用应用于这些谓词的
我的应用程序中有一个非常简单的 CUDA 组件。 Valgrind 报告了很多泄漏和仍然可以访问的问题,所有这些都与 cudaMalloc 调用有关。 这些泄漏是真的吗?我打电话cudaFree每 c
在 chrome latest 和其他浏览器中测试。此页面启动一个 timer() 每 60 秒刷新一次。在 init() 和每个 refresh() 上,它从服务器获取数据并在页面中显示相同的数据。
我正在尝试使用 pprof 来验证内存泄漏。 能否解释一下如何阅读您在以下位置找到的堆配置文件:http://localhost:6060/debug/pprof/heap?debug=1 此外,在启
我们遇到了由 GroovyShell/Groovy 脚本引起的内存泄漏(请参阅最后的 GroovyEvaluator 代码)。主要问题是(从 MAT 分析器复制粘贴): The class "java
我在 Ubuntu 中使用带有延迟长度字符变量的 gfortran 8.4,如下例所示: PROGRAM test IMPLICIT NONE CHARACTER(LEN=:),ALLOC
我正在阅读 Efficient Android Threading,上面写着 Instead of using nested classes with outer class references,
我们最近将我们的应用程序从 Java 7 迁移到 Java 8。从切换之日起,我们开始看到内存不足的元空间问题。我们尝试增加元空间空间大小,但没有帮助。 Jvisual VM(和 Jconsole)显
使用最新版本的 FFmpeg 读取图像文件时我遇到了内存泄漏,我无法追踪。 好像填完AVFrame与 avcodec_send_packet和 avcodec_receive_frame ,我调用av
我们有某种泄漏,我不明白其性质。 Gen0/1/2 堆的大小不会增加,但是工作集会增加,直到我们 OOM。 DebugDiag 告诉我 CLR.DLL 拥有不断增加的内存,并告诉我我们有一个不断增长的
一位系统管理员告诉 med,内存泄漏是不可见的。即,如果应用程序正在泄漏内存,则应用程序使用的所有内存可能在任务管理器或等效工具中不可见。 他似乎对此非常肯定。我一直认为在任务管理器(或进程资源管理器
我们正在自动化大多数可以自动化的已知问题(用于回归测试)。但是,我们确实通过第三方软件发现了内存泄漏。但是,我不知道如何自动执行我们发现并修复它们的内存泄漏测试。 有什么建议吗? 最佳答案 通常最好的
如果我有一个垃圾收集器来跟踪分配的每个对象并在它们不再具有对它们的可用引用时立即释放它们,您是否仍然存在内存泄漏? 考虑到内存泄漏是没有任何引用的分配不是不可能的还是我错过了什么? 编辑:所以我算作内
我有一个托管在 IIS 中的 WCF 应用程序(用 C#/.Net 4 编写)。随着时间的推移,进程的句柄计数或多或少以线性方式增加(在进程回收之前增加到 30,000)。根据 SysInternal
我从LeakSanitizer工具获得以下输出。正如工具所了解的那样,直接泄漏和间接泄漏有什么区别? 13: ==29107==ERROR: LeakSanitizer: detected memor
首先我是这样跑的: valgrind --leak-check=full --show-leak-kinds=all test_proc 和日志: ==30349== For counts of de
我知道每个进程都有操作系统分配的自己的地址空间。所以当程序终止时,整个地址空间都被标记为无效(或者可以再次自由重用)。现在,如果上述进程正在泄漏内存,那么在程序终止后会产生什么影响吗? 也就是说,如果
我是一名优秀的程序员,十分优秀!