title: How can I get the Total Memory and the Free Memory from OSX so that I can use it from a PHP program?
body: <p>I'm working on a system that was developed for linux and that needs the Total Memory of the machine and the Free Memory.</p>
  
  <p>For that, the system used the /proc/ folder of linux to get that data, but mac doesn't have that folder.</p>
  
  <p>Two days ago I got bored of running a virtual machine on my computer only to be able to test and started making the program compatible with mac.</p>
  
  <p>Because of that I started evaluating different methods, but none worked.</p>
  
  <p>The most popular answers that you can see on internet if you search for this problem are the following:</p>
  
  <ul>
  <li>free (-bash: free: command not found // It doesn't exist in mac).</li>
  <li>Top (I was able to look at the info in the console, but I wasn't able to retrieve it from the code).</li>
  </ul>
  
  <p>But because of the reasons I added between the parenthesis, they are not useful.</p>
  
  <p>How can I get the Total Memory and the Free Memory on a mac computer so that I can use it from a program?</p>
  
  <hr>
  
  <p>NOTE: I am working on php. If you have a php solution, it will work, but I prefer a general solution.</p>