1 2 Previous Next 15 Replies Latest reply: Feb 24, 2014 5:08 AM by Imantas Imantas RSS

java.lang.OutOfMemoryError: PermGen space

shawn aslam Newbie

I found this error even when deploying the application or now when application is running. I read all the discussion on this topic and changed the run.conf's JAVA_OPT of jboss 5.0.1ga (on window) as below

 

JAVA_OPTS="-Xms128m -Xms512m -XX:PermSize=128m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"

 

 

In the start problem resolved but now after 5 days application stop working and when i check the logs it start giving this error.So this statement for the time being is not the permanent solution and i need to do something to put the fix.

Somewhere I found that changing this line in run.conf will not have any effect in window server.So should i need to make this change in the run.bat if yes then where should i write this line? secondly is there anything I need to make change in the JAVA_OPTS above statement?

  • 1. Re: java.lang.OutOfMemoryError: PermGen space
    Miklós Kasza Newbie

    Hello Shawn,

     

    MaxPermSize of 512m should be more than enough for the most applications, so you may be right in that the AS might ignore your desired settings.

    Simply put, the file run.conf is used only when running the AS under Unix-like systems (by starting the script named run.sh).

    On Windows systems run.bat (together with run.conf.bat in later AS versions) can be used for launching the AS.

     

    Additionally, as a rule of thumb you should tamper only with jvm options you are familiar with (e.g., memory-related ones) others can be safely left at defaults. Otherwise they may affect the performance of your application in a negative way.

     

    You can write your additions anywhere near the original lines starting with "set JAVA_OPTS..."

     

    Additionally, you should monitor the memory consumption (by using jvisualvm or a similar tool) of your server in order to be able to set memory levels appropriately.

     

    Hope this helps.

  • 2. Re: java.lang.OutOfMemoryError: PermGen space
    Wolf-Dieter Fink Master

    First of all I strongly recommend that you update to JBoss 5.1 because of bugfixes, you should not use 5.0 any longer.

  • 3. Re: java.lang.OutOfMemoryError: PermGen space
    Wolf-Dieter Fink Master

    Regarding the PermGenSpace problem:

    Do you use hotdeployment? This can be a problem.

    How do you start the JBoss, as service?

    With JBoss 5.1 you can change the options within the run.conf.bat file.

    But as Miklós say 512m is enough PermGen in most cases.

     

    If you still have the problem you should analyze the objects with a heap dump or a java-profiler.

  • 4. Re: java.lang.OutOfMemoryError: PermGen space
    shawn aslam Newbie

    I start the Jboss through service.....

    I set the following parameters to the run.bat.conf by hoping AS will pick from here next time

    set "JAVA_OPTS=-Xms128M -Xmx512M -XX:MaxPermSize=512M -XX:+CMSClassUnloadingEnabled"

    Do i need to restart the Jboss after that?

    Secondly when I run the VisualVM from the Jdk\bin it has the status as below.

    VisualVM.png

    and also please find below the detail of VisualVM which might help you to fix the issue

     


    Version:

    1.6.0_23 (Build 100930); platform 100909-1140d3a55456

    System:

    Windows 2003 (5.2) Service Pack 1, x86 32bit

    Java:

    1.6.0_23; Java HotSpot(TM) Client VM (19.0-b09, mixed mode)

    Vendor:

    Sun Microsystems Inc., http://java.sun.com/

    Environment:

    Cp1252; en_US (visualvm)

    Userdir:

    C:\Documents and Settings\shamid\Application Data\.visualvm\6u23

    Clusters:

    C:\Program Files\Java\jdk1.6.0_23\lib\visualvm\platform
    C:\Program Files\Java\jdk1.6.0_23\lib\visualvm\visualvm
    C:\Program Files\Java\jdk1.6.0_23\lib\visualvm\profiler

    Visit https://visualvm.dev.java.net for more information. Built on NetBeans Platform.

     

     

     

     

  • 5. Re: java.lang.OutOfMemoryError: PermGen space
    Miklós Kasza Newbie

    Every time you change options in the startup scripts you have to restart the AS in order to apply those changes (since options appearing in these files are passed to the JVM during startup and then get left alone by the server).

     

    You can check the actual (applied) values by opening the file boot.log (in the server/<config>/log folder). The value of VM arguments shows how the AS's boot mechanism sees the options passed to the JVM. If the values of your choice are not appearing there, the settings are certainly misplaced.

     

    Unfortunately, your screenshot can't be displayed by my browser (at least for the moment).

  • 6. Re: java.lang.OutOfMemoryError: PermGen space
    Wolf-Dieter Fink Master

    To see your visualVM information you should attach the picture (use JPG as most common) because I can't also not get it

  • 7. Re: java.lang.OutOfMemoryError: PermGen space
    shawn aslam Newbie

    here you go the picture in jpg

     

    VisualVM.jpg

  • 8. Re: java.lang.OutOfMemoryError: PermGen space
    Wolf-Dieter Fink Master

    PermGen looks not full because 27MB of 63MB used, you get the picture at the wrong time?

     

    You should monitor the memory with jstat or get a heap history dump, see http://www.oracle.com/technetwork/java/javase/tooldescr-136044.html

    Or look ito the troubleshooting guide here : http://www.oracle.com/technetwork/java/javase/memleaks-137499.html

  • 9. Re: java.lang.OutOfMemoryError: PermGen space
    Miklós Kasza Newbie

    One additional remark: the Max value of 64 megabytes shows that the analysed VM has the maximum size of permanent generation space setting set to 64m. The reasons can be:

    • your options are not recognized by the VM (see my previous comment)
    • you are not monitoring the VM you really want to monitor: this is more probable, since based on your screenshot you are monitoring the jVisualVM process itself, not a JBoss instance. When running both jVisualVM and a JBoss AS on the same host you should see something like this (if you are monitoring remotely, you have to add the JBoss instance as a Remote Host instead):

                   jvisualvm-jboss-tree.png

  • 10. Re: java.lang.OutOfMemoryError: PermGen space
    shawn aslam Newbie

    yes you right Kasza that in production webserver i am not able to see the java application running on that machine not even the jboss ...

    Tell me one thing if i am running the jboss through window service would that be a issue for VisualVM to list it down.

    What should i do so that VisualVm start listing the jboss?

    Secondly as per discussion i check the boot.log and found below the only related VM argument line

    09:43:00,065 INFO  [ServerInfo] VM arguments: -Dprogram.name=run.bat -Xrs -Djava.endorsed.dirs=C:\jboss-5.1.0.GA\\lib\endorsed

    which is obviously not the one i given in the run.bat.conf.....

    Also as i already posted the detail found in the VisualVM and also posting below which might help you finding the issues of VisualVM

    why it is saying mixed mode though...


    Version: 1.6.0_23 (Build 100930); platform 100909-1140d3a55456

    System: Windows 2003 (5.2) Service Pack 1, x86 32bit

    Java: 1.6.0_23; Java HotSpot(TM) Client VM (19.0-b09, mixed mode)

    Vendor: Sun Microsystems Inc., http://java.sun.com/

    Environment: Cp1252; en_US (visualvm)

    Userdir: C:\Documents and Settings\shamid\Application Data\.visualvm\6u23

    Clusters: C:\Program Files\Java\jdk1.6.0_23\lib\visualvm\platform
    C:\Program Files\Java\jdk1.6.0_23\lib\visualvm\visualvm
    C:\Program Files\Java\jdk1.6.0_23\lib\visualvm\profiler

     

    I really want to monitor the permgen memory to avoid the future issues related to this so guys your help in this regard will be much appreciated.

     

  • 11. Re: java.lang.OutOfMemoryError: PermGen space
    Peter Johnson Master

    There is a known issue that the setting of JAVA_OPTS in service.bat prevents the JAVA_OPTS in run.conf.bat from taking place. To fix this, comment out (or delete) the "if" line in run.conf.bat, like this (new stuff in red):

     

    rem if not "x%JAVA_OPTS%" == "x" goto JAVA_OPTS_SET

     

    And you will also have to change the first line that sets JAVA_OPTS to (new stuff in red):

     

    set "JAVA_OPTS=%JAVA_OPTS% -Xms128M -Xmx512M -XX:MaxPermSize=256M"

     

    Alternatively, you can set all of the JVM options in service.bat, just add them to this existing line:

     

    set JAVA_OPTS=-Xrs

  • 12. Re: java.lang.OutOfMemoryError: PermGen space
    shawn aslam Newbie

    Thanks peter putting the java_opts line into service.bat has resolved the issue and now i can see the argument in the boot.log file.

    Now the only remaining thing is VisualVm is not showing the JBOSS so that i can verify that it uses the require permgen memory.

  • 13. Re: java.lang.OutOfMemoryError: PermGen space
    shawn aslam Newbie

    Guys dont you have anything for me on this topic anyfurther?

  • 14. Re: java.lang.OutOfMemoryError: PermGen space
    Peter Johnson Master

    I would not use VisualVM to monitor the JBoss AS in production because VisualVM puts a load on any Java app that it monitors. It you wnat to monitor heap and pergen usage in a production environment, use the jstat utility instead.

1 2 Previous Next