Setting Tomcat Heap Size (JVM Heap) in Eclipse

apache-tomcat-eclipseRecently while running Tomcat under Eclipse for one of the web application I was getting Java Heap memory related error java.lang.OutOfMemoryError.
What needs to be done here basically is to increase the jvm heap size. So for increasing the JVM Heap Size of Tomcat in Eclipse we have to set few VM arguments of the tomcat.

Follow the simple steps to change the Heap Size of Tomcat under Eclipse.
1. Open the Server tab in Eclipse and double click the Tomcat server to open Server Configuration.
eclipse-tomcat-tab

2. In Server Configuration, click on the Launch Configuration link under General Information.
tomcat-config-eclipse

3. Under Arguments tab, add following values in VM arguments.

-Xms64m -Xmx256m

tomcat-jvm-config
To know more about -Xm options read this article.



30 Comments

  • jens 17 November, 2009, 7:09

    hi,

    thanks so much for this great and helpful blog post!!! it helped me such much, thanks!!!!

    jens

  • nitin 1 July, 2010, 14:07

    Thank you very much for the screen shots..!

  • darfat 21 July, 2010, 9:07

    thanks, for this briliant article,!!

  • goldo 30 August, 2010, 20:27

    Hi,
    Thx for the tip ;)
    Is there a way to persist this change in an external config file (or other) to avoid edit launch configuration each time eclipse is restarted ?
    Thx in advance.

  • aldo 20 October, 2010, 20:50

    tnx

  • David 21 January, 2011, 6:43

    ¡Great post! Thanks from Mx

  • Geoff 1 March, 2011, 1:09

    Awesome – love succinct articles that get to the point AND are spot on.

  • Murali 21 March, 2011, 18:19

    Thanks, This helped me.

  • navneet 29 March, 2011, 8:54

    thanks its really helpfull

  • Serkan 21 June, 2011, 18:30

    Thanks mate, it is very helpful

  • Sandeep 24 June, 2011, 13:51

    bang on the target! thanks :)

  • Badal 10 August, 2011, 0:05

    awesome…to the point..thanks

  • Ritesh 18 October, 2011, 9:43

    Hi,
    Could any one explain the advantage of initializing the instance variables inside a constructor, the same thing we can do after the object has been initialized and calling the respective setters method.

  • Edrisse 18 February, 2012, 12:40

    You are the man. I looked for this so bad. Thanks.

  • mohan 17 August, 2012, 5:14

    How do we set VM arguments in tomcat running outside of eclipse like from dos prompt ?
    JAVA_OPTS ?

  • Srikanth 23 September, 2012, 14:52

    This helped me.. Thank you so much!!

  • Gozde 24 September, 2012, 17:30

    You really helped me to save a lot of time, thank you so much!!!

  • JavaGirl 17 October, 2012, 5:28

    This is really helpful. Thank you very much!

  • krish 26 November, 2012, 20:06

    thank u for u r answer

  • kark 28 February, 2013, 14:23

    its working well when we read a large size article first time, if you read the second time that file, it shows Same heap space problem

  • Jahir 6 March, 2013, 1:29

    It is really great, thanks :)

  • Rob 16 April, 2013, 18:19

    Thanks! That works fine! :-)

  • Gustavo 9 June, 2013, 19:12

    Man, your solution is the only one that has worked for me, thanks a lot, keep up the good work

  • senthil 12 June, 2013, 10:32

    Fantastic man….

  • Mou 26 July, 2013, 15:42

    Can you tell me the max Limitation for JVM Heap Space.My requirement is to increase the heap size more than 1 GB…Can you suggest me an idae…..

    • Rama Yaganti 12 December, 2013, 20:47

      Max Limitations of heap space is depends on your Server capacity & Ram. For 1Gb there wont be problem . if you have 8 gb ram there wont be problem to keep you Heap size limited to 2 Gb

  • Rifaquat 2 January, 2014, 10:52

    Thnx viral i was finding solution from last nyte i found it here in very easy way….
    Thnx

  • suraj 6 February, 2014, 11:57

    really a good information …
    bt i want to increase permgen memory ….
    do you know how to ?
    then do let mi know..

  • Rakhunathan 27 May, 2014, 14:00

    Setting vmargs in Eclipse.ini to the below and then making the above change in tomcat worked for me.:)
    -vmargs
    -Xms256m
    -Xmx1024m
    -XX:PermSize=64m
    -Xss1M
    -server
    -XX:+DoEscapeAnalysis

  • faariz 3 November, 2014, 11:39

    But Still my problem is not solved. It is saying that,”java.lang.OutOfMemoryError: PermGen space”

Leave a Reply

Your email address will not be published. Required fields are marked *

Note

To post source code in comment, use [code language] [/code] tag, for example:

  • [code java] Java source code here [/code]
  • [code html] HTML here [/code]