title: How to determine CPU and memory consumption from inside a process
body: <p>I once had the task of determining the following performance parameters from inside a running application:</p>
  <ul>
  <li>Total virtual memory available</li>
  <li>Virtual memory currently used</li>
  <li>Virtual memory currently used by my process<hr></li>
  <li>Total RAM available</li>
  <li>RAM currently used</li>
  <li>RAM currently used by my process<hr></li>
  <li>% CPU currently used</li>
  <li>% CPU currently used by my process</li>
  </ul>
  <p>The code had to run on Windows and Linux. Even though this seems to be a standard task, finding the necessary information in the manuals (WIN32 API, GNU docs) as well as on the Internet took me several days, because there's so much incomplete/incorrect/outdated information on this topic to be found out there.</p>
  <p>In order to save others from going through the same trouble, I thought it would be a good idea to collect all the scattered information plus what I found by trial and error here in one place.</p>