Click here to Skip to main content
15,665,942 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey guys I am just wondering does anyone know how to get memory usage from a WMI command. I can get the CPU easily enough but struggling with the memory.

What I have so far

ManagementScope ms = new ManagementScope(@"\\" + server.Value + @"\root\cimv2");
SelectQuery sq = new SelectQuery("select * from Win32_PerfFormattedData_PerfOS_Processor");
ManagementObjectSearcher mos = new ManagementObjectSearcher(ms, sq);
   foreach (System.Management.ManagementObject mo in mos.Get())
      var usage = mo["PercentProcessorTime"];

Thanks guys


Check this link:
How To: (Almost) Everything In WMI via C# Part 2: Processes[^]

This may give you an idea :)
Share this answer
It depends entirely on what you mean by 'memory usage'.

You can start by using Win32_OperatingSystem class:[^]

Example here:[^]
Share this answer
frostcox 20-Nov-14 13:49pm    
excellent thanks very much.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900