Ok well you can't actually increase the heapsize, but you could spawn another process with a new heapsize.
Have a play with this:
public class SpawnAndChangeHeap {
public static void main(String[] args){
//Get the jvm heap size.
long heapSize = Runtime.getRuntime().totalMemory();
JOptionPane.showMessageDialog(null, "" + heapSize );
if(args.length > 0 && args[0].equals("-spawn")) {
try {
Process proc;
proc = Runtime.getRuntime().exec("cmd.exe /c java -Xms32m -Xmx128m SpawnAndChangeHeap /n");
}
catch(Exception e) {System.out.println("something went wrong"); }
}
System.exit(0);
}
}