Instant SharePoint Memory Usage

Memory usage is a big deal when you are deploying new web parts or applications - mainly because you need to see if you have any memory leaks - which mostly stems from not Disposing of your SPWeb and SPSite objects properly...

The easiest way to see what is going on is to simply open Windows Task Manager, click on the Processes tab, sort by Image Name, find the w3wp.exe processes, and look at the Mem Usage.

Of course the system needs to be under a load... If the system is not a production system, then you may want to set up ACT to apply a load. Perhaps a subject for another blog...

It is easy to recognize a memory leak - the Mem Usage will slowly grow higher and higher under load until the app pool recycles (if it is set to recycle).

What can make it a bit more complicated is when you have more than one Web Application on a web server. How do you tell which w3wp process corresponds to a particular Web Application?

In Windows Task Manager click on View and Select Columns andĀ check the PID (Process Identifier), Peak Memory Usage and Thread Count.

The important oneĀ for identifying the app pool is the PID (the others just provide additional important info).

To get a list of the names of the Web Applications that correspond with each PID, open a Command Window and enter:

cd c:\windows\system32

and then:

c:\windows\system32>iisapp.vbs

If this instant way of gauging your memory usage doesn't give you all the information you need, then you can fire up Performance Monitor (PerfMon), set up some counters and even log those counters so you can see what's going on over a longer period of time.

Start > Run type PerfMon and hit enter.

If you right click on the graph in PerfMon you'll see an option to "Add Counters". This is where it starts to get complicated, since you need to know which counters to use... Perhaps yet another subject for yet another a blog entry...