scifio/scifio — pull request #191 by dscho (2014-06-06 23:50:03+00:00)
Title: Fix the estimation of the remaining free memory

Java has a funny memory concept. It lets users specify a maximum amount of
RAM to use, but it does not allocate all of it at once.

Therefore, there are three different memory values relevant to our
estimate: the amount of memory *currently* allocated, the maximum memory
Java will try to allocate, and the remaining free of the *currently*
allocated memory. These three values are available via java.lang.Runtime's
totalMemory(), maxMemory() and freeMemory() methods, respectively.

What we are *actually* interested in, though, is the *maximal* amount of
remaining memory, including the one Java will only allocate when asked to.
Therefore, we actually need to use the formula free + max - total.

Signed-off-by: Johannes Schindelin