Is it possible to determine if an object is being

2020-06-06 07:22发布

I have a memory leak in my C# program and cannot determine who is holding the reference to my object. Is there a way at runtime to determine which objects are holding a reference to a specific object?

In this economy my budget is zero, so a native or free solution is my only choice.

标签: c#
3条回答
放我归山
2楼-- · 2020-06-06 07:35

For a free tool take a look here. This article discusses how to use the free tools from MS (windbg/sos) to find memory leaks in managed code. The interface is not pretty, but it gets the job done. Here is a link to windbg.

查看更多
家丑人穷心不美
3楼-- · 2020-06-06 07:39

I learned how to debug memory leak issues from here http://blogs.msdn.com/tess/archive/2008/03/17/net-debugging-demos-lab-6-memory-leak.aspx

using the debugging tools for windows

the learning curve is pretty steep, but once you get it, it's a great skill to have

查看更多
爷的心禁止访问
4楼-- · 2020-06-06 07:50

Check out .NET Memory Profiler. They have a 14 day free trial (so your budget is safe). Excerpt from the features page ...

For a managed type instance the following additional information is presented:

  • References from and to the instance

Per comments: Agree 100% ... well worth the very reasonable license fee.

查看更多
登录 后发表回答