5 Replies Latest reply on Jul 11, 2008 12:20 PM by Peter Johnson

    OutOfMemory Error when redeploying application

    Manleon Manleon Newbie

      Hello All,

      I am using Eclipse 3.3 and JBoss 4.2.2. Now I have developed one application in eclispe and deploy that in JBoss from within Eclipse. Now while the server is on, I make some changes in Java files and now I redeploy my application. Now after redeploying my application I hit the login page of the application where I get following Error :-

      org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/perfex-servlet.xml]: Invocation of init method failed; nested exception is java.lang.OutOfMemoryError: PermGen space
      Caused by:
      java.lang.OutOfMemoryError: PermGen space
      10:52:41,719 ERROR [[/perfex]] Servlet /perfex threw load() exception
      java.lang.OutOfMemoryError: PermGen space


      I am having 512MB of RAM.

      Can anybody help me with this issuse. As such I am new to JBoss so i dont know from where to make any memory or allocation configurations.

      Even when i start JBoss alone by copying the war file in deploy directory, my application works fine at first cut. Then i delete that war file from the deploy directory and application in undeployed while server is on. Then when i again paste the war file in deploy directory the JBoss will give same error mentioned above.

      Thanks in Advance

        • 1. Re: OutOfMemory Error when redeploying application
          Peter Johnson Master

          I was going to provide some help on this but based on your next question (http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4163654) which you posted several hours later, I get the feeling you got past this error. If not, let me know.

          • 2. Re: OutOfMemory Error when redeploying application
            Manleon Manleon Newbie

            Thanks Peter for ur cooperation.

            And sorry for creating the confusion if any. Actaully this error is not related to eclipse of any such IDE (also mentioned in detailed post).

            My war file if of 50MB. Now assume i am not starting eclipse at all or assume that eclipse is not in the picture. Now I am copying the war file in deploy folder of defaul config and then start the JBoss server. JBoss will deploy my application and I can use if smoothly. Now keep the server on I remove the war file. So JBoss will undeploy my application. No I make some changes in the Java files make the war file again and copy it in deploy folder again with server running. JBoss will again deploy my application. But when I hit the link to home page of my application now it will give me the mentioned OutOfMemory error. Also I try to access the web-console application to see if there is any problem in my applicaiton or not. But even the web-console application of JBoss will wont work too.

            So now I am confused of where this OutOfMemory error could be.

            Regarding my other post, it is a seperate error. Even if i deploy the application for the first time in eclipse, the server will time out. (no discussions regarding that post here. just briefing on that). So that is a seperate concern all together.

            And as u said OutOfMemory error is more crucial, even my self is desperate to find solution to this problem first.

            Please provide me the solution/guidelines on the same.

            I think this might make the picture clear.

            Thanks in advance.

            • 3. Re: OutOfMemory Error when redeploying application
              jaikiran pai Master

              What JVM memory configuration have you set in the run.bat file? The wiki has some explanation on the OOM errors:

              http://wiki.jboss.org/wiki/OutOfMemoryExceptions

              And since you mention, that this OOM happens on a redeploy, see this too

              http://wiki.jboss.org/wiki/OutOfMemoryExceptionWhenRedeploying

              • 4. Re: OutOfMemory Error when redeploying application
                Manleon Manleon Newbie

                Thanks Peter and Jaikiran.

                @Jaikiran. Both of your wiki links were very useful and I gained a lot.

                @Peter. I referend to ur posts in following topic

                http://www.jboss.com/index.html?module=bb&op=viewtopic&t=115689

                As the solution suggests I have increased the Perm Gen space by adding a parameter in run.bat to a size of 128MB.

                Yes I have got the solution and now even if i redeploy no error comes even if I redeploy 2 to three times. And thanks for that.

                But from the output of PrintHeapAtGC I am confused at one thing. First let me show u the output after the server is on for the first time and my application is deployed for the first time.

                {Heap before gc invocations=113:
                 def new generation total 13184K, used 13034K [0x03a60000, 0x048a0000, 0x07340000)
                 eden space 11776K, 100% used [0x03a60000, 0x045e0000, 0x045e0000)
                 from space 1408K, 89% used [0x04740000, 0x0487abc0, 0x048a0000)
                 to space 1408K, 0% used [0x045e0000, 0x045e0000, 0x04740000)
                 tenured generation total 116544K, used 54035K [0x07340000, 0x0e510000, 0x23a60000)
                 the space 116544K, 46% used [0x07340000, 0x0a804dc8, 0x0a804e00, 0x0e510000)
                 compacting perm gen total 131072K, used 47427K [0x23a60000, 0x2ba60000, 0x2ba60000)
                 the space 131072K, 36% used [0x23a60000, 0x268b0fb0, 0x268b1000, 0x2ba60000)
                No shared spaces configured.
                [GC 67070K->55756K(129728K), 0.0364396 secs]
                Heap after gc invocations=114:
                 def new generation total 13184K, used 1060K [0x03a60000, 0x048a0000, 0x07340000)
                 eden space 11776K, 0% used [0x03a60000, 0x03a60000, 0x045e0000)
                 from space 1408K, 75% used [0x045e0000, 0x046e9008, 0x04740000)
                 to space 1408K, 0% used [0x04740000, 0x04740000, 0x048a0000)
                 tenured generation total 116544K, used 54696K [0x07340000, 0x0e510000, 0x23a60000)
                 the space 116544K, 46% used [0x07340000, 0x0a8aa2d0, 0x0a8aa400, 0x0e510000)
                 compacting perm gen total 131072K, used 47427K [0x23a60000, 0x2ba60000, 0x2ba60000)
                 the space 131072K, 36% used [0x23a60000, 0x268b0fb0, 0x268b1000, 0x2ba60000)No shared spaces configured.
                }
                


                Now with my application deployed perm gen space is used 36%. Fine.

                Now I undeploy the application from the server while keeping it running. And after few minutes of time this is the output of GC.
                {Heap before gc invocations=199:
                 def new generation total 13184K, used 12548K [0x03a60000, 0x048a0000, 0x07340000)
                 eden space 11776K, 100% used [0x03a60000, 0x045e0000, 0x045e0000)
                 from space 1408K, 54% used [0x04740000, 0x04801160, 0x048a0000)
                 to space 1408K, 0% used [0x045e0000, 0x045e0000, 0x04740000)
                 tenured generation total 116544K, used 94782K [0x07340000, 0x0e510000, 0x23a60000)
                 the space 116544K, 81% used [0x07340000, 0x0cfcf8d0, 0x0cfcfa00, 0x0e510000)
                 compacting perm gen total 131072K, used 70680K [0x23a60000, 0x2ba60000, 0x2ba60000)
                 the space 131072K, 53% used [0x23a60000, 0x27f66110, 0x27f66200, 0x2ba60000)
                No shared spaces configured.
                [GC 107330K->95565K(129728K), 0.0289821 secs]
                Heap after gc invocations=200:
                 def new generation total 13184K, used 185K [0x03a60000, 0x048a0000, 0x07340000)
                 eden space 11776K, 0% used [0x03a60000, 0x03a60000, 0x045e0000)
                 from space 1408K, 13% used [0x045e0000, 0x0460e548, 0x04740000)
                 to space 1408K, 0% used [0x04740000, 0x04740000, 0x048a0000)
                 tenured generation total 116544K, used 95380K [0x07340000, 0x0e510000, 0x23a60000)
                 the space 116544K, 81% used [0x07340000, 0x0d065260, 0x0d065400, 0x0e510000)
                 compacting perm gen total 131072K, used 70680K [0x23a60000, 0x2ba60000, 0x2ba60000)
                 the space 131072K, 53% used [0x23a60000, 0x27f66110, 0x27f66200, 0x2ba60000)
                No shared spaces configured.
                }
                


                Now here we can see perm gen space is used 53% and I have my application undeployed. Also I have not hit the server URL even once.

                So here my doubt is even by increasing the perm gen space It will just increase the longevity of the server life before the error comes. But the error is suppose to come in near future.

                Is my understanding correct. Or am I really perplexed by the system's internal stuff.

                Please provide me guiding lines.

                Thanks in Advance

                • 5. Re: OutOfMemory Error when redeploying application
                  Peter Johnson Master

                  You are correct in being alarmed. Redeployment is always a tricky business - the old classes will be released only if there are no more references to them. So if there are issues with the code, you could each time increase the amount of permgen space used each time you redeploy. (If your do a forum search for permgen out of memory error you will see that a lot of others have run into this.) A profiling tool, or heap analysis tool, might help you determine which classes are still in use and who is using them.

                  This is one of the reasons why turning off the hot deployer is recommended for production use.