I\'m trying to sort a bunch of data such that that the size of data input to the program can be larger than the memory available to the JVM, and handling that requires exter
Check out these methods on the java.lang.Runtime class:
freeMemory
totalMemory
maxMemory
Example
Runtime rt = Runtime.getRuntime();
System.err.println(String.format("Free: %d bytes, Total: %d bytes, Max: %d bytes",
rt.freeMemory(), rt.totalMemory(), rt.maxMemory()));
Also note that if the total amount of memory is being exhausted you can always start the JVM with a larger amount of heap allocated using the -Xmx JVM argument; e.g.
java -Xmx256M MyClass