How to detect where a Memory Leak is?

后端 未结 12 1662
感动是毒
感动是毒 2020-12-13 11:00

I have a large website that seems to be sucking up all the memory that is being allocated. There is nothing else on the server beside this site. Within a week it eats away t

相关标签:
12条回答
  • 2020-12-13 11:49

    Do you have lots of dynamic pages on your site?

    You can also try IBM's Purify

    I suggest you try with a small set of dynamic pages disabling all others for the meantime. I hate to say this but it's very much possible that IIS 7 may also have leaks.

    0 讨论(0)
  • 2020-12-13 11:52

    Check out the Memory and Memory Leak labs on this blog post:

    .NET Debugging Demos

    They may be of some help. Basically, you can use WinDBG to analyze a memory dump and help determine what is eating up all of your memory.

    We used a similar approach to determine that Regex was chewing up all of our memory, but only when the product was run on 64-bit machines. The learning curve is kind of steep, but WinDBG is a very powerful tool.

    0 讨论(0)
  • 2020-12-13 11:53

    Run a profiler on your code.

    Here are two good options:

    RedGate's memory profiler

    Jetbrains dotTrace

    I believe both products have a free trial.

    0 讨论(0)
  • 2020-12-13 11:53

    This is probably prevention rather then detection, but at the c# code level, you should check that any classes that use large resources such as images and other files are correctly implementing the dispose pattern. If needed you may also need to override the finalizer.

    MSDN has good guidance on this subject.

    If you have any classes in your application that you know make use of large resources, these are the first places to look for memory issues.

    0 讨论(0)
  • 2020-12-13 11:53

    Look at this article on detecting .NET application memory leaks and related articles mentioned at the bottom of the page and hopefully you will find a solution or at least an idea to resolve it.

    Thanks

    0 讨论(0)
  • 2020-12-13 11:55

    This new article of mine maybe useful: How to detect and avoid memory and resources leaks in .NET applications

    0 讨论(0)
提交回复
热议问题