Sumit Kumawat

Sumit Kumawat

  • NA
  • 454
  • 405.5k

how to get Free Physical Memory of OS using c#?

Nov 20 2017 3:35 AM
Hi all,
I want to fetch the FreePhysicalMemory of os using c#,
for this im writing WMI qquery below is my code
 
ObjectQuery wql = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(wql);
ManagementObjectCollection results = searcher.Get();
 
foreach (var result in results)
{
//Free amount
Free = Convert.ToInt32( result["FreePhysicalMemory"]);
}
but the value i am getting is not matching with task manager's value.currenty i am using window 7 OS.
plz tell me if there is any other way to get accurate value
TIA 

Answers (1)