How to Change Java Heap Space
Command-Line (Per Application)
1. Open a command window (Windows) or terminal/shell window (Unix/Linux) and navigate to the application you wish to run.
2. To indicate an initial heap size, run your program with the following parameters:java -Xms
(your application command line)For example, to run MyApp.jar with a starting heap size of 64 MB, you would run it like so:java -Xms64m -jar MyApp.jar
3. To indicate a maximum heap size, change your command line to the following:java -Xms
-Xmx
(application command line)Assuming we want the example from step two to run with a maximum heap size of 128 MB, use the following command line:java -Xms64m -Xmx128m -jar MyApp.jarThis will ensure the application starts off with a minimum of 64 MB of heap space allocated for it, and never tries to allocate more than 128 MB.
Control Panel (System Wide/For Applets)
4. On Windows operating systems, open your control panel ('Start menu > Control Panel') and find the icon labeled 'Java.' (This may not be available in earlier versions of Java.)
5. In the Java Control Panel application, go to the 'Java' tab and click the 'View...' button. You'll be presented with a window containing a list of the installed Java Runtime Environments on your system.
6. Select your primary (or only) Java environment from the list and double-click in the cell labeled 'Runtime Parameters.'
7. Enter the initial and maximum heap sizes as necessary, using the parameters used in the first section above. For example, to use an initial heap size of 64MB and a maximum heap size of 128MB, fill in the box with the following:-Xms64m -Xmx128m
8. Click 'OK' to close the runtime environments window, and 'OK' again to close the Java control panel.