title: Get physical memory usage in megabytes
body: <p>I am looking for away to get the current amount physical memory used in MB. Something like in the Task Manager </p>
  
  <p><img src="https://i.stack.imgur.com/28k8t.png" alt="enter image description here"></p>
  
  <p>I am current using <code>PerformanceCounter("Memory", "Available MBytes", true);</code> but its also including the page files (I believe) which is not what I want. Also I want the option of getting the used and not the available memory.</p>
  
  <p>The application I am working on, will monitor the physical memory usage, until the desired threshold is reached.  Then it will restart a few windows services. </p>
  
  <p>If you curious as to why I am developing such a program.  Some of our programs have memory leaks on the servers, and a we have to restart windows services to release the memory, until we sort out all the memory leaks, I am making this application to help keep the server going, and responsive. </p>