Programatically summing all the processes on the host machine.

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

Greetings,

IF one wanted to get the memory utilization just like the windows task manager
does .. what do you need to sum? .. if I add together all the processes I'm
still short ..

my snippet

private Int64 total_mem_usage()
{
Int64 memUsed = 0;

System.Diagnostics.Process[] PrsArr = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process p in PrsArr)
{
memUsed += p.WorkingSet64;
}

return memUsed;
}
 
IF one wanted to get the memory utilization just like the windows task manager
does .. what do you need to sum? .. if I add together all the processes I'm
still short ..

my snippet

private Int64 total_mem_usage()
{
Int64 memUsed = 0;

System.Diagnostics.Process[] PrsArr = System.Diagnostics.Process.GetProcesses();
foreach (System.Diagnostics.Process p in PrsArr)
{
memUsed += p.WorkingSet64;
}

return memUsed;
}

WMI might work:

http://tinyurl.com/397m2b
"In this article, Steve demonstrates how to get memory size usage using
WMI and .NET 2.0. The information returned is the same as listed in Task
Manager."
 
Back
Top