• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.lang.OutOfMemoryError: PermGen space

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm running jboss 4.2.0 on Red Hat EL, and I'm getting this "java.lang.OutOfMemoryError: PermGen space" error.
When I have a look at the log, the default for JAVA_OPTS is -Xms128m -Xmx512m, even though I could not find it set anywhere in run.sh (I can, though, find it in run.bat).
I'm planning to increase the maximum memory size to 1024: -Xmx1024m by adding: JAVA_OPTS="-Xms128m -Xmx1024m $JAVA_OPTS"

My questions are:
1. Is it possible to increase the maximum size of the memory?
2. Why is this option not in run.sh but it is in run.bat?
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

1. Is it possible to increase the maximum size of the memory?



Yes, its possible. You can add your heap settings to the run.sh file (for JAVA_OPTS) similar to what you see in the run.bat file. You will have to decide what values are appropriate for your application.
 
Ruby Martinus
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jaikiran,

Thanks for you answer for my first question. I've got the answer to question 2. It is actuallly in run.conf file for Linux/Unix.
The problem that I'm having is actually the PermGen space, not the Heap Space. I increased the PermGen space and it is now working fine so far (fingers crossed).
[ July 23, 2007: Message edited by: Ruby Martinus ]
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

How to increase Permgen space for jboss 4.2.2 GA. Modifying JAVA_OPTS in run.conf file enough or not?

Can i increase numbers 512 to 1024 directly or need to add any tags at the end ?

Please help me out. Thanks in advance.

Sridhar.
 
Ranch Hand
Posts: 1179
Mac OS X Eclipse IDE
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The defaut PermGen space in Jave is 64MB, and you want to define a larger one.
To do so you need to set the two params -XX:PermSize=128m and -XX:MaxPermSize=128m in the JAVA_OPTS - the size is here set to 128MB - but you can set it to your own, it have to be below the max of -Xmx
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Why this happens?

The "PermGen" error happens, when the Java virtual machine runs out of memory in the permanent generation. Recall that Java has a generational garbage collector, with four generations: eden, young, old and permanent.
In the eden generation, objects are very short lived and garbage collection is swift and often.
The young generation consists of objects that survived the eden generation (or was pushed down to young because the eden generation was full at the time of allocation), garbage collection in the young generation is less frequent but still happens at quite regular intervals (provided that your application actually does something and allocates objects every now and then).
The old generation, well, you figured it. It contains objects that survived the young generation, or have been pushed down, and garbage collection is even less infrequent but can still happen.
And finally, the permanent generation. This is for objects that the virtual machine has decided to endorse with eternal life - which is precicely the core of the problem. Objects in the permanent generation are never garbage collected; that is, under normal circumstances when the jvm is started with normal command line parameters.
So what happens when you redeploy your web application is, that your WAR file is unpacked and its class files loaded into the jvm. And here's the thing: almost always ends up in the permanent generation...
(taken from: http://rlogiacco.blogspot.com/2009/02/jboss-and-permgen-outofmemoryerror.html)



Here are some advices I saw:
  • use this parameters for your JVM. they tell the Garbage Collector to invoke its algorithm also on the PermGen.
    set JAVA_OPTS=-Xms512m -Xmx512m
    -XX:PermSize=128m
    -XX:MaxPermSize=512m
    -XX:+UseConcMarkSweepGC
    -XX:+CMSPermGenSweepingEnabled
    -XX:+CMSClassUnloadingEnabled

    The CMSPermGenSweepingEnabled setting includes the PermGen in a garbage collection run. By default, the PermGen space is never included in garbage collection (and thus grows without bounds).
    The CMSClassUnloadingEnabled setting tells the PermGen garbage collection sweep to take action on class objects. By default, class objects get an exemption, even when the PermGen space is being visited during a garabage collection.
    (taken from: http://community.eapps.com/showthread.php?p=537)

  • Restart your JBOSS because each time you deploy application, you increase the amount of data in the PermGen.

  • Use JRocket JVM instead of the Sun JVM. it doesn't have any PermGen in its Garbage Collector algorithm.



  • in case you wand simple JSP file to monitor your memory you can find it here:
    http://www.freshblurbs.com/explaining-java-lang-outofmemoryerror-permgen-space
     
    author
    Posts: 5856
    7
    Android Eclipse IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I would never use the CMS collector with less than 1GB of heap space. And I would not use the CMS collector unless I understood what effect it had on my application and system in general. Never ever ever use the CMS collector on a single CPU system. I would not turn it on unless I had at least 4 CPUs.

    Do not rely on any undocumented options - their availability and behavior change from version to version. Stick to the options available here:
    http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp unless you want to get the source for the JVM you are using and looking up the current usage. For example, in JVM 6 the -XX:+CMSPermGenSweepingEnabled option results in a warning to use -XX:+CMSClassUnloadingEnabled instead.

    Also, the statement that the GC ignores the permgen is not entirely true - if you turn on one of the GC monitoring options (PrintHeapAtGC, I think), you will often see the collector releasing classes from the permgen. OK, in the source I see this comment:



    So turning on the CMS collector turns off permgen cleaning unless you turn that cleaning back on.

     
    Yaron Rel
    Greenhorn
    Posts: 20
    • Likes 1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi again,
    If you have done all that and still get this error, I have 1 more advise: Make sure you change the JAVA_OPT value only after JBOSS initializes it!
    otherwise, JBOSS would skip its initialization.
    To my opinion, the best place to do that is at the end of the following file:
    WINDOWS: JBOSS_HOME/bin/run.conf.bat
    UNIX: JBOSS_HOME/bin/run.conf
     
    Ew. You guys are ugly with a capital UG. Here, maybe this tiny ad can help:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic