6 Replies Latest reply on Apr 14, 2009 8:48 AM by marcos_aps

    java.lang.OutOfMemoryError: PermGen space (RichFaces 3.3.0.G

    marcos_aps

      Hello, everybody!

      First of all, that's what I'm using for development:

      - JBoss 4.2.3.GA
      - Java 5 Update 18
      - RichFaces 3.3.0.GA
      - Eclipse 3.4.2

      This is the first time that I'm trying RichFaces, but I'm constantly getting this error (I'm running the application in Eclipse):

      Caused by: java.lang.OutOfMemoryError: PermGen space
       at java.lang.ClassLoader.defineClass1(Native Method)
       at java.lang.ClassLoader.defineClass(Unknown Source)
       at java.security.SecureClassLoader.defineClass(Unknown Source)
       at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1814)
       at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:872)
       at org.jboss.web.tomcat.service.WebAppClassLoader.findClass(WebAppClassLoader.java:75)
       at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1325)
       at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
       at java.lang.ClassLoader.loadClassInternal(Unknown Source)
       at org.ajax4jsf.resource.ResourceBuilderImpl.registerConfig(ResourceBuilderImpl.java:160)
       at org.ajax4jsf.resource.ResourceBuilderImpl.registerResources(ResourceBuilderImpl.java:144)
       at org.ajax4jsf.resource.ResourceBuilderImpl.init(ResourceBuilderImpl.java:215)
       at org.ajax4jsf.renderkit.ChameleonRenderKitFactory.<init>(ChameleonRenderKitFactory.java:62)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
       at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
       at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
       at java.lang.reflect.Constructor.newInstance(Unknown Source)
       at javax.faces.FactoryFinder.getImplGivenPreviousImpl(FactoryFinder.java:560)
       at javax.faces.FactoryFinder.getImplementationInstance(FactoryFinder.java:459)
       at javax.faces.FactoryFinder.getFactory(FactoryFinder.java:260)
       at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:186)
       at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:131)
       at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:202)
       at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:195)
       at org.jboss.web.jsf.integration.config.JBossJSFConfigureListener.contextInitialized(JBossJSFConfigureListener.java:71)
       at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3856)
       at org.apache.catalina.core.StandardContext.start(StandardContext.java:4361)
       at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:790)
       at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:770)
       at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:553)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      


      I've already changed the default Eclipse's configuration for the JVM from this:

      -vmargs
      -Xms40m
      -Xmx512m
      


      to this:

      -vmargs
      -Xms512m
      -Xmx1024m
      -XX:MaxPermSize=256m
      


      I also change JBoss memory configuration in run.bat from this:

      set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m
      


      to this:

      set JAVA_OPTS=%JAVA_OPTS% -Xms512m -Xmx1024m
      


      and, even though it has got a little better, I'm still getting the error. This
      is my configuration for RichFaces in web.xml:

      <filter>
       <display-name>RichFaces filter</display-name>
       <filter-name>richfaces</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
      </filter>
      
      <filter-mapping>
       <filter-name>richfaces</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
      </filter-mapping>
      


      So, I'm not using skins. The machine where I'm working has 1GB of RAM memory.

      What can I do to get rid of this out of memory error?

      Thank you.

      Marcos

        • 1. Re: java.lang.OutOfMemoryError: PermGen space (RichFaces 3.3
          nbelaevski

          Hi Marcos,

          Add -XX:MaxPermSize=128m to JBoss startup script and try.

          • 2. Re: java.lang.OutOfMemoryError: PermGen space (RichFaces 3.3
            marcos_aps

             

            "nbelaevski" wrote:
            Hi Marcos,

            Add -XX:MaxPermSize=128m to JBoss startup script and try.


            Thanks for you replay, nbelaevski.
            I made the change suggested by you, but I'm still getting the error after more or less 8 redeployments of my application to the server. What about the other memory paramets configuration in JBoss, -Xms and -Xmx ? The default values in run.bat are:

            JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m
            


            What about the Eclipse configuration too? The default values are:

            -vmargs
            -Dosgi.requiredJavaVersion=1.5
            -Xms40m
            -Xmx512m
            -XX:MaxPermSize=256m
            


            Do I also have to change these?

            Marcos

            • 3. Re: java.lang.OutOfMemoryError: PermGen space (RichFaces 3.3
              nbelaevski

              Eclipse configuration does not affect JBoss. -Xmx and -Xms won't solve your issue also. Are you using any third-party libraries?

              • 4. Re: java.lang.OutOfMemoryError: PermGen space (RichFaces 3.3
                marcos_aps

                The only library that I'm using in my application, besides RichFaces, is Apache Tiles (version 2.0.5).
                I must say that when I was not using RichFaces I also had the out of memory problem, but after more or less 70 or more redeployments in the same session in Eclipse. Now the problem appears just after more or less 7 or 8 redeployments. So RichFaces added a lot of things to the memory.

                Marcos

                • 5. Re: java.lang.OutOfMemoryError: PermGen space (RichFaces 3.3
                  djkrite

                  I run RichFaces and about 18 other libraries in my app. I havn't counted my redeployments using netbeans, but I can go a least 4 hours before restarting JBoss. I have 3G of ram and running Ubuntu. Here's my JBoss flags:

                  JAVA_OPTS="-server -Dprogram.name=run.sh -Djava.net.preferIPv4Stack=true -Xms1g -Xmx1g -Xmn128m -XX:PermSize=384m -XX:MaxPermSize=384m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled
                  


                  Tom

                  • 6. Re: java.lang.OutOfMemoryError: PermGen space (RichFaces 3.3
                    marcos_aps

                     

                    "djkrite" wrote:
                    I run RichFaces and about 18 other libraries in my app. I havn't counted my redeployments using netbeans, but I can go a least 4 hours before restarting JBoss. I have 3G of ram and running Ubuntu. Here's my JBoss flags:
                    JAVA_OPTS="-server -Dprogram.name=run.sh -Djava.net.preferIPv4Stack=true -Xms1g -Xmx1g -Xmn128m -XX:PermSize=384m -XX:MaxPermSize=384m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled
                    


                    Tom


                    Hello, Tom!
                    I have tried your JBoss configuration and I'm still getting the error early.
                    My machine runs Windows XP Update 3 and has 1GB memory. Maybe I have to increase the memory, but before that I think I'll switch from RichFaces to the Prototype library alone as I only need basic Ajax support in a few pages for the moment. I'm aware that RichFaces is a great technology and I would like to use it, as it would give me a great gain in productivity, but this memory problem just doesn't let me work. Thank you.

                    Marcos