title: dynamically increasing java heap space
body: <p>I have written a java program that tests the speed of a couple of multi-threading algorithms on different machines with various numbers of processors. </p>
  
  <p>On some machines, merge sort* fails because it requires a sizable heap space to work on very large arrays. I can easily change the java heap space myself before running the program, but I feel like a more robust and easy approach would be to do this task from within the program itself.</p>
  
  <p><strong>Is there a way to request/achieve more heap space from the virtual machine <em>during the course of a java program?</em></strong></p>
  
  <p>Note: I do understand that I could execute the program with a script like "java -Xmx1g Program"; my curiosity on this subject is in part academic. </p>
  
  <p>*My implementation does NOT merge in-line. It requires O(n) extra memory.</p>