Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find memory leak in ASP.NET Web App

I'm hosting 7 websites on a single production server (virtual) at 2.53 Ghz (2 CPU) and 8GB of RAM on WIN SERVER 2008 R2 Enterprise 64 Bit.

Web server is IIS 7 and all of the websites are with .NET Framework 4.0 application pool.

My current memory usage is about 4.16 GB out of 8GB and w3wp.exe is the most process which consuming most of the memory usage (about 1.6 GB at this time) followed by sqlservr.exe with (1.5 GB) usage.

What I would like to do is to know which website out of 7 is consuming the most memory so that I could have a look.

I've tried Process Explorer and Resource monitor but it could only show how much rem taken by w3wp.exe but not individual website's usage.

Is there a way where I could pin point the memory hogger?

like image 388
Ye Myat Aung Avatar asked Oct 01 '12 08:10

Ye Myat Aung


People also ask

How can we detect memory leak in ASP Net web application?

Start the debug diagnostic tool and select 'Memory and handle leak' and click next. Select the process in which you want to detect memory leak. Finally select 'Activate the rule now'. Now let the application run and 'Debugdiag' tool will run at the backend monitoring memory issues.

How do you find memory leaks on the app?

The Memory Profiler is a component in the Android Profiler that helps you identify memory leaks and memory churn that can lead to stutter, freezes, and even app crashes. It shows a realtime graph of your app's memory use and lets you capture a heap dump, force garbage collections, and track memory allocations.

How does dotnet detect memory leaks?

Using “Making Object ID” to find memory leaks Set a breakpoint where the class instance is created. To open the debugger's data-tip, hover over the variable, then right-click and select Make Object ID. To verify that the Object ID was created correctly, type $1 in the Immediate Window.


1 Answers

You could do a memory dump using Microsoft's Debug Diag tool.

Basic process is:

  • Launch DebugDiag
  • Cancel Wizard
  • Click "Processes" tab
  • Select w3wp
  • Right-click and select "Create full dump"
  • Snigger quietly to yourself because you said "dump"
  • Once dump is complete (snigger again), click "Advanced Analysis" tab
  • Use the 2 Memory Pressure Analyser scripts to see if you can see what objects are using a lot of memory.

I would advise doing this in combination with Uri May's answer, as otherwise you will likely waste a lot of time.

like image 165
RB. Avatar answered Sep 25 '22 22:09

RB.