17

I am trying to increase the max heap size for my Eclipse. I have tried specifying in eclipse.ini or through the command line, but are not working.

My max heap size has the exact same limit before (running jconsole) and after (System.out.println(java.lang.Runtime.getRuntime().maxMemory());) starting Eclipse. 1.8G

  1. Is there any way to modify JVM heap size before it is launched (ex. a config file?)
  2. What could I be doing wrong when specifying heap size to Eclipse?

This is the command:

./eclipse/eclipse -debug -consoleLog -vmargs -Xms1000m -Xmx6000m -XX:-UseGCOverheadLimitcl

This is my eclipse.ini (which values are overwritten by the specified eclipse launching parameters):

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20120522-1813
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Dhelp.lucene.tokenizer=standard
-XX:MaxPermSize=6000m
-Xms1000m
-Xmx6000m
trincot
  • 317,000
  • 35
  • 244
  • 286
Inigo Llamosas
  • 457
  • 1
  • 4
  • 12

4 Answers4

28

It is possible to increase heap size allocated by the Java Virtual Machine (JVM) by using command line options.

-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size
-Xss<size>        set java thread stack size

If you are using the tomcat server, you can change the heap size by going to Eclipse/Run/Run Configuration and select Apache Tomcat/your_server_name/Arguments and under VM arguments section use the following:

-XX:MaxPermSize=256m
-Xms256m -Xmx512M

If you are not using any server, you can type the following on the command line before you run your code:

java -Xms64m -Xmx256m HelloWorld

More information on increasing the heap size can be found here

Community
  • 1
  • 1
slashdot
  • 766
  • 5
  • 11
  • This is the only thing that has worked for me so far, that is, specify at every runtime in eclipse the Xmx etc. arguments. I am running my own hadoop, mahout etc. programs in my laptop in pseudo distributed mode. – Inigo Llamosas Jan 18 '13 at 09:18
  • I know it's two years old, but it's baffling that this answer has so many upvotes. It does nothing to answer the question, which is specifically about Eclipse, and which already shows an understanding of setting the heap size from the command line. And what does Tomcat have to do with anything? – Martin McCallion Jun 18 '15 at 14:33
  • 1
    @MartinMcCallion It has so many upvotes because when when people google thing like "increase jvm ECLIPSE" this is one of the topics that comes up....and for everyday developers that use tomcat with eclipse this is helpful information. – Doc Holiday Sep 21 '15 at 13:35
  • is there any other way to edit heap size in eclipse (From properties) – Rick Nov 29 '16 at 10:56
14

You can use this configuration:

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20120913-144807
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Xms512m
-Xmx1024m
-XX:+UseParallelGC
-XX:PermSize=256M
-XX:MaxPermSize=512M
Krrishnaaaa
  • 689
  • 11
  • 23
Bourkadi
  • 738
  • 1
  • 7
  • 17
4

Try to modify the eclipse.ini so that both Xms and Xmx are of the same value:

-Xms6000m
-Xmx6000m

This should force the Eclipse's VM to allocate 6GB of heap right from the beginning.

But be careful about either using the eclipse.ini or the command-line ./eclipse/eclipse -vmargs .... It should work in both cases but pick one and try to stick with it.

Aleš
  • 8,896
  • 8
  • 62
  • 107
  • I tried running just ./eclipse/eclipse -debug -consoleLog, and modified the eclipse.ini. Not working. I have to say I am user inigo but I run this command as sudo. If I do it as inigo I get problems with dependencies. – Inigo Llamosas Jan 18 '13 at 09:12
  • 1
    How do you check for the heap size. Could you use `jstat -gccapacity`? you can also enable logging `-XX:+UnlockDiagnosticVMOptions -XX:+LogVMOutput -XX:LogFile=jvm.log` to see which parameters are in the end passed into the VM. – Aleš Jan 18 '13 at 18:52
2

--launcher.XXMaxPermSize

256m

Try to bump that value up!

gprathour
  • 14,813
  • 5
  • 66
  • 90
Luke
  • 21
  • 1