c#.net-有没有办法在运行时确定我的应用程序的每个类/对象类型的内存使用情况?
我有一个在云(Heroku)中运行的C#.NET应用程序,并且我不时会遇到内存泄漏。
我想在运行时从应用程序中获得详细的内存使用统计信息,因为我无法将调试器附加到远程过程。
如果我可以在运行时从C#代码内部获得类似follwing的东西:(
> dumpheap -stat
Statistics:
MT Count TotalSize Class Name
...
00007f6c1eeefba8 576 59904 System.Reflection.RuntimeMethodInfo
00007f6c1dc021c8 1749 95696 System.SByte[]
00000000008c9db0 3847 116080 Free
00007f6c1e784a18 175 128640 System.Char[]
00007f6c1dbf5510 217 133504 System.Object[]
00007f6c1dc014c0 467 416464 System.Byte[]
00007f6c21625038 6 4063376 testwebapi.Controllers.Customer[]
00007f6c20a67498 200000 4800000 testwebapi.Controllers.Customer
00007f6c1dc00f90 206770 19494060 System.String
Total 428516 objects
来源: https://learn.microsoft.com/en-us/dotnet/core/diabore/diagnostics/debug-memory-leak-leak )
我到目前为止都找不到任何东西,均未:免费库,第三方工具和代码段。
I have a C# .NET app running in the cloud (Heroku) and from time to time I'm experiencing memory leaks.
I would like to get a detailed memory usage statistics from my app, in runtime, because I cannot attach a debugger to the remote process.
It would be great if I could get something like the follwing from inside of my C# code during runtime:
> dumpheap -stat
Statistics:
MT Count TotalSize Class Name
...
00007f6c1eeefba8 576 59904 System.Reflection.RuntimeMethodInfo
00007f6c1dc021c8 1749 95696 System.SByte[]
00000000008c9db0 3847 116080 Free
00007f6c1e784a18 175 128640 System.Char[]
00007f6c1dbf5510 217 133504 System.Object[]
00007f6c1dc014c0 467 416464 System.Byte[]
00007f6c21625038 6 4063376 testwebapi.Controllers.Customer[]
00007f6c20a67498 200000 4800000 testwebapi.Controllers.Customer
00007f6c1dc00f90 206770 19494060 System.String
Total 428516 objects
(source: https://learn.microsoft.com/en-us/dotnet/core/diagnostics/debug-memory-leak)
I was unable to find anything so far, neither of: a free library, a third party tool nor a code snippet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 dotmememory 。此工具将向您显示内存泄漏建议,总内存,每个类型对象的内存...
You can use DotMemory. This tool will show you memory leak suggestion, total memory, memory of each type object...