Debugging .NET memory leaks - how to know what is holding a reference to what?

后端 未结 5 1817
眼角桃花
眼角桃花 2021-01-02 13:12

I am working on a .NET application where there appears to be a memory leak. I know the text-book answers, that events should be unsubscribed, disposable objects should be di

5条回答
  •  醉话见心
    2021-01-02 14:04

    Debugging memory leaks can be quite involved process and requires thorough understanding of your program logic and at least some .Net internals (especially garbage collector behaviour).

    For more information see the following links:

    Good introduction

    • http://msdn.microsoft.com/en-us/library/ee658248.aspx

    Hands-on course:

    • http://www.dotnetfunda.com/articles/article508.aspx
    • http://www.dotnetfunda.com/articles/article524.aspx

    GC and .Net internals

    • http://blogs.msdn.com/b/tess/archive/2008/04/17/how-does-the-gc-work-and-what-are-the-sizes-of-the-different-generations.aspx
    • http://msdn.microsoft.com/en-us/magazine/cc163491.aspx
    • http://blogs.msdn.com/b/maoni/archive/2004/06/03/148029.aspx

    WinDbg with SOS extension

    • http://www.codeproject.com/Articles/19490/Memory-Leak-Detection-in-NET
    • http://www.simple-talk.com/dotnet/.net-framework/investigating-.net-memory-management-and-garbage-collection/

    Good Luck!

提交回复
热议问题