If you are running a program in eclipse and want the execution to happen with a specific value of heap size, –
- Right click on application -> Run as.. -> Run Configurations -> Open Argument tab
- Now, under VM arguments, specify :
Here, change the values 128 and 256 with numbers you want to specify. Value given with -Xms (128m) is minimum heap size and value given with -Xmx (256m) is maximum heap size. Value of max memory for JVM can be retrieved using API Runtime.getRuntime().maxMemory().