Find which w3wp.exe instance is hosting your application

Just a quick and easy one for this Friday evening: let’s say you have multiple w3wp.exe instances running on your web server (maybe you have multiple application pools, or you enabled Web Garden etc…), one of the ASP.NET applications you have on that server has some problems and you need to capture a memory dump to troubleshoot it: what can you do?

Easy one: install the Debugging Tools for Windows and run adplus with something like the following:

cscript adplus.vbs -hang -pn w3wp.exe

But, hey, you don’t want to end up with a full dump for every w3wp.exe loaded in memory, you just need one of them, the one which is hosting your application… smile_eyeroll

Well… here is where iisapp.vbs comes to the rescue! smile_regular You can find it under C:\Windows\System32 folder on your Windows 2003 machine, and if you simply run it at the command line, it’ll print to the console the PID of all w3wp.exe processes running and the Application Pool ID that particular process is hosting; here is a screenshot I just took in my machine:

iisapp vbs output

Since you are supposed to know under which application pool your application is running (and if you don’t know you can check it through the IIS Management Console) you are ready to go! Let’s say I want to dump an application running under "Live" App Pool:

cscript adplus.vbs -hang -p 4612

Here we go; not comes the tricky (and funny) part: analyze the dump smile_nerd