Solving Tomcat OutOfMemoryError: Heap space and PermGen space

It’s quite common to run In memory problems when running some big Java EE application on a Tomcat server.
Some of the most commmon errors are like the following ones.

This is about a full Heap space:

SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.OutOfMemoryError: Java heap space

This other is about the PermGen space that’s a memory area, where compiled classes (and JSPs) are kept, and this error might happen often if the running web application have many .java and .jsp.

MemoryError: PermGen space
java.lang.OutOfMemoryError: PermGen space

To increase the memory available to Tomcat, about heap and permgen the correct options are the following ones.

This sets the max heap available to Tomcat at 1Gb of memory:

--JvmMx 1024

This sets the max permgen available to Tomcat at 256Mb of memory:

-XX:MaxPermSize=256m

To change the Tomcat memory settings (when Tomcat is installed on Windows as system service), it’s required to use the command-line tool tomcat6. The next command changes the memory settings for the Tomcat service named Tomcat6

tomcat6 //US//Tomcat6 --JvmMx 1024 ++JvmOptions="-XX:MaxPermSize=256m"

The label //US//Tomcat6 has the meaning of Updating Server parameters for the service named Tomcat6.
Obviously this command should be executed from the directory C:\Program Files\Apache Software Foundation\Tomcat 6.0\bin or from wherever is the bin directory of your Tomcat installation. Or to make things simple, that directoy should be added to your PATH environment variable.

It’s even possible to update memory settings from a GUI frontend, or to view what happened after running the command line tool. Running the following command:

tomcat6w //ES//Tomcat6

a window will open showing all the parameters about the windows service Tomcat6.

It’s possible to see in this image that, after running the previous command, for setting higher memory limits, in the sections Maximum memory pool and at the end of the Java Options the new memory limits are set.

Tomcat Memory Settings on Windows

Tomcat Memory Settings on Windows

97 thoughts on “Solving Tomcat OutOfMemoryError: Heap space and PermGen space

  1. Now single Russian girls can also be getting career oriented and strive hard despite of every one of the opposition and conflicts to get a stable professional &
    social life. Most software results in sites that rely extensively on PHP
    and My – SQL. The following are five questions you should ask (or get strategies to)
    before meeting with your matches with a real first date.

  2. Pingback: apache - Tomcat 7 CreateJavaVM de Error de Error de

  3. Pingback: apache - Tomcat 7 mise en CreateJavaVM d'Erreur Échec de l'

  4. Thank you for every other great post. The place else could anybody
    get that kind of information in such an ideal means of writing?
    I have a presentation subsequent week, and I’m at the search for such information.

  5. Wonderful blog! Do you have any suggestions for aspiring writers?

    I’m planning to start my own site soon but I’m a little
    lost on everything. Would you propose starting
    with a free platform like WordPress or go for a paid option?
    There are so many options out there that I’m totally overwhelmed ..
    Any recommendations? Cheers!

  6. Sbobet is a trusted gambling site that operates to help all fans of online gambling in the world.
    Founded in 2010, it didn’t agree to long for Sbobet to become
    the biggest online site in Asia and similar to it
    comes to the amount of betting money that rotates all week, Sbobet is in addition to one of the
    biggest sites in the world.

    Sbobet is categorically popular, especially along with Asian bettors, the
    reason is that the site has been awarded as the best gambling operator for two years in a row.
    It offers a variant of football betting following unquestionably low
    margins gone compared to additional sites in its class.

  7. agreeable to Mabosbola, one of the best Indonesian Sbobet agents before 2010.
    Mabosbola.com is Indonesia’s largest Sbobet site that will be
    next to you to international gambling game services. afterward
    several world sites, Mabosbola is an agent site that gives you full permission to various gambling game categories.

    In supporting the services and comfort of our members, Mabosbola is always glad to allow satisfaction to members
    who trust us as Sbobet Indonesia agents. Various popoler gambling betting markets upon Sbobet and as a consequence Maxbet and many others.
    We preserve our title as master agent because of our fine bill both in terms of help and fast payment.
    Not to forget afterward our role as a betting clash for the world
    mug and the Euro as well.

  8. Alternate Link l69
    L69 is among the official sites that provide the most
    recent alternative link trustworthy online
    betting sites. L69 provides more than 1 alternative link from each and every betting site, and all of us here have become one of the most comprehensive alternative link companies and the L69 site includes a responsive display that will makes it
    easy that you should access our site coming from the display of
    your own tool or laptop. In addition to what you need to know
    is that will we here just have one official link, l69. me
    personally and if there usually are other websites that provide information or call our
    website is not the official site.
    Ball betting and casino gambling usually are types of
    games that are incredibly favored by the folks of Indonesia.

    Why l69? Because we’ve been here for a lot more than five a number of possess become the trust regarding the
    individuals of Philippines as a location to play soccer gambling as well
    as on the internet casino gambling. Itself has additionally obtained a license from the Asian and Western governments last year to become an online gambling betting provider site in Asian countries and
    Europe. By offering lots of different types of wagering bets
    that can be played upon one ID, much more the members feel happy playing in your bookie.

    Great things about Alternative Links l69
    Yet sadly lately there are usually many members who encounter problems and problems whenever entering into
    their Sgd777 game since the Sbobet internet site is usually blocked and many older sites have been blocked by the Indonesian authorities and never
    a few are usually also influenced with what is called the Newsletter
    Job. The Indonesian government recently is struggling to eradicate links or paths to
    access sites that smell associated with pornography,
    gambling and there are a number of other content of which is deemed inappropriate.

  9. I think that what you said was actually very reasonable.
    But, consider this, suppose you were to write a killer post title?
    I ain’t saying your content is not solid., however suppose you added a title to maybe grab people’s attention? I mean Solving Tomcat OutOfMemoryError: Heap
    space and PermGen space | Web2.0 Tutorials is kinda plain. You
    could peek at Yahoo’s home page and note how they create
    news titles to grab viewers interested. You
    might try adding a video or a picture or two to grab readers interested about everything’ve got
    to say. Just my opinion, it could bring your posts a little
    livelier.

Leave a Reply

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