...and Xmx should be 9999G...
Unfortunately, the Sun JVM (now Oracle main JVM) "array cells are consecutive in memory" blocks this. When the JVM reports "free memory = T" it must be able to allocate an array of size T. However, due to the aforementioned feature, this require the JVM to pre-allocate all the memory so it can reshuffle everything to be able to allocate that array in consecutive memory addresses. So why didn't they (Sun, now Oracle) drop this feature? Because it helps tremendously in signal and image processing, allow you to fine-tune memory-based optimizations and, usually, offers better array instantiation speed.
Long computations which yield zero are probably all for naught.