Do Java Virtual Machine (JVM) implementations increase their memory at runtime if required?
Note that the Sun virtual machine implementations have command line parameters that can tell it how much memory to use initially, and how much memory it can use maximally (how much the VM's memory usage can grow to). If you don't specify these parameters, the VM uses defaults. I believe that the default maximum is typically 32 megabytes. If your Java application is going to need to use more than this, you'll have to start the VM with these extra parameters.
The parameters are: -Xms and -Xmx you can see help for these parameters by typing "java -X" on the command-line.