开发者

How to write memory usage log in ASP.NET

We got "out of memory" issue on production servers. What API can we use to get live memory (physical and managed) usage of the ASP.NET application?

开发者_如何学Python

Thanks.

PS: we're forbidden to profile memory with tools.


Also an Out of memory doesn't necessarily mean what you think. heavy memory fragmentation due to excessive object creation can be reported as out of memory since the GC is not able to find a continuous block of memory large enough for next (or last attempted) allocation.


.Net performance counters can help you with a number of managed memory related stats.

This page details some of the ones available- http://msdn.microsoft.com/en-us/library/x2tyfybc.aspx

You can use normal windows memory counters to get an overview of non-managed memory- http://msdn.microsoft.com/en-us/library/aa965225(VS.85).aspx


Well, the first thing that I can suggest you is to take a memory dump when your w3wp.exe usage is high. You should takes these dumps and analyze it yourself, or get an expert to do it.

http://blogs.msdn.com/tess will tell you how if you are interested in doing it.

BUT... before you do any of the real exercise... two things that you absolutely must do.

  1. Turn Debug = False in all your web.config files http://aspalliance.com/1341

  2. Turn Trace = False in all your web.config files since the trace data is maintained in your memory and worsens memory shortage.


in addition to the performance counters you could use the profiling tools shipped with Visual Studio in order to monitor the memory usage. This step can help you on identifing memory issues before the code is released to production. Here's how to do it with VS2010: http://msdn.microsoft.com/en-us/library/dd264934.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜