How to get the size of available system memory?

Viewed 81192

Is it possible to get the size of system available memory in C#.NET? if yes how?

6 Answers
var performance = new System.Diagnostics.PerformanceCounter("Memory", "Available MBytes");
var memory = performance.NextValue();

A piece of codes:

 System.Diagnostics.PerformanceCounter ramCounter;     
 ramCounter = new System.Diagnostics.PerformanceCounter("Memory", "Available Bytes"); //"Available MBytes" for MB
 string getAvailableRAMInBytes = ramCounter.NextValue() + "byte";
Related