title: Problem with Runtime.freeMemory() - Java
body: <p>Hey I'm testing out Runtime.freeMemory() with this code:</p>
  
  <pre><code> Runtime runtime = Runtime.getRuntime();
   long freeMemory = runtime.freeMemory();
  
   // This is some arbitary factor that should work &lt;= 1
   double factor = 0.8;
  
   int size = (int) (factor * freeMemory);
   byte[] testArray = new byte[size];
  </code></pre>
  
  <p>I'm creating a byte array of size close to the freeMemory value. For some reason, especially when I limit the memory of the program to around 8MB, the code throws an OutOfMemory exception for any factor > 0.55. This really doesnt make sense, surely freeMemory means freeMemory, I expect it to be a little out, but not double what actually is free.</p>
  
  <p>Any suggestions on whats going on? 
  Thanks</p>
  
  <p>(Note in my tests im limiting the memory available to the program to 8MB or 16MB, using -Xmx8M etc.)</p>