How to increase heap memory of your java application in Eclipse
13,658
Solution 1
If you go to Run -> Run Configuration in the Arguments Tab you will find the VM Arguments
section where you can add this.
Sample Entry in VM Arguments
-Xms50M -Xmx128M
In Program Arguments
you mention the arguments which will be passed to the Main Class.
Solution 2
Go to the eclipse.ini file in Eclipse directory.
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20130225-1645.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20130228-0336
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Xms1152m
-Xmx1152m
and change
**openFile
-vmargs
-Xms1152m
-Xmx1152m**
accordingly.
Author by
Enrico
Updated on June 14, 2022Comments
-
Enrico almost 2 years
can anyone teach me how to increase your heap size using arguments like -Xms1024m -Xmx1024m ? What is the difference of Program argument and VM argument?
-
Enrico over 10 yearsSo which argument will be carried by the jar file? I'm wondering if the jar I am creating retains this max values i set in these argument
-
Ajay George over 10 years@user2655077 There will be none which will be retained in the jar file that you create.To run your jar you need to pass these params from cmd line.
java -Xms50M -Xmx128M -jar yourjar.jar
-
Ajay George over 10 yearsOP is not asking about increasing eclipse's memory.
-
Enrico over 10 yearsI think I'm enlightened by that @Ajay George.. ^^
-
Master over 10 yearsYes but sometimes you need to, to run large apps on Eclipse. To change it simply go to your eclipse directory and change in eclipse.ini it should work definitely.
-
Enrico over 10 yearsnow my problem is how much memory should i allocate to my app? The server where this app is running has 32G memory..
-
Ajay George over 10 years@user2655077 that would be a very difficult question to answer without knowing more about your app. Why don't you start by giving it 1G and see whether that suffices.
-
Enrico over 10 yearsi have allocated 2 gb and after few seconds it throws OOM
-
Ajay George over 10 yearstry bumping it up to 4 G and enable -XX:-HeapDumpOnOutOfMemoryError to get the heap dump. Use it to analyze which objects are taking up most memory.