Best way to find memory leaks? RRS feed

  • Question

  • Hi,

    Lets say your application has (probably) a memoryleak which makes it use over 1GB memory and you have no idea to reproduce this yourself because your application is so big. Only when looking on the Server you see users run your .net application at an insanly high memory usage.  You can go visit them .... but can anything be done at this point?

    and the next question, which is the best profiling application. I've used DotTrace, it's a good profiler application, a very good even, but for finding memory leaks i've had troubles making good use of it..... so what's the best Memory Leak find application? AQTime? I've read good things about this but haven't tried it.

    If possible i'd like to find a program whichs shows which Method and which object causes the memory leak ;)

    thanks for reading,

    Wednesday, January 14, 2009 5:32 PM


  • There are many .net profilers but I would suggest using Memprofiler or Red Gate .NET memory profiler. However you could use profiler only if you can re-create this issue at will. Anoher thing is, your profiler will make your server crawl under large load.

    If you can't recreate this issue at will but it only occurs on some unknown condition, I would suggest using WinDBG(download from microsoft debugging tools for windows). When the virtual memory usage is high, you can just take the memory dump of the process and  find the roots. It will probably be easy to find objects increasing on managed heap in generation 2 if you take the multiple memory dump at a set intervals. You can use ADPlus.vbs script to automate that.

    If you have no experience with WinDBG you can read my blog or ask me any question you may have but the best managed debgging blog is from Tess

    • Marked as answer by Zhi-Xin Ye Wednesday, January 21, 2009 8:17 AM
    Wednesday, January 14, 2009 6:48 PM