Search code examples
c#iisapplication-pooliis-10

Finding memory usage of multiple App Pools using c#


I'm attempting to find how much of each App Pool's memory is being used through c#

This is what I have at the moment:

List<ApplicationPool> pools = new List<ApplicationPool>();
List<WorkerProcess> processes = new List<WorkerProcess>();

ServerManager serverManager = new ServerManager();
ApplicationPoolCollection appPools = serverManager.ApplicationPools;

foreach (ApplicationPool pool in appPools)
{
    pools.Add(pool);
}

This gives me a list of all the App Pools I have running, but none of the properties of the ApplicationPool object give me any information about it's usage or and real-time data.

Have I got completely got the wrong end of the stick?

How do I find out the information I want?

I haven't been able to find a straight answer anywhere, but apologies if this has been answered before.

Cheers


Solution

  • You could use system.diagnostics to get the working set.

    The example in the link could be modified to get the working set for all w3wp.exe processes.

    Is there a way to retrieve a C# app's current memory usage?.