9 Replies Latest reply on Dec 20, 2012 10:32 AM by Christian Sadilek

    possible memory leak in dev mode with errai

    mojoo mojoo Newbie

      hello,

      my team and i are developing a "big" application based on gwt 2.5 ,errai 2.1 and jboss as 7.1. We have several hundred distinct views, each with presenter, view and dto on client side. We make excessive use of client side dependency injection, databinding and event handling. As the project grew larger we noticed that after some browser refreshes in dev mode the codeserver just stopped responding. Passing more memory to the codeserver made it last longer but now after 1 or two reloads, the process uses up the 4gb memory. I made a heap dump and realised that most memory (>85%) is used by object instances of class types:

       

      org.jboss.errai.codegen.meta.impl.java.JavaReflectionClass

      org.jboss.errai.codegen.meta.impl.gwt.GWTClass

      org.jboss.errai.codegen.meta.impl.build.BuildMetaClass

       

      maybe this is a known problem and someone could give us some help here ?

       

      thanks in advance

        • 1. Re: possible memory leak in dev mode with errai
          Christian Sadilek Master

          Hi,

           

          After looking into this we fixed a memory leak that occurs when using Errai's UiBinder module. Are you using this by any chance? If so, updating to the latest 2.2.0-SNAPSHOTs should fix (or at least significantly improve) the problem.

           

          Here's the JIRA:

          https://issues.jboss.org/browse/ERRAI-456

           

          Cheers,

          Christian

          • 2. Re: possible memory leak in dev mode with errai
            mojoo mojoo Newbie

            No not using this, tried anyway but didnt helped. thanks for the quick response

            • 3. Re: possible memory leak in dev mode with errai
              Christian Sadilek Master

              OK thanks for letting us know. To see if there's a memory leak in Errai involved in your case, you could compare heapdumps before and after a DevMode referesh and investigate the instance counts of e.g. org.jboss.errai.codegen.meta.impl.gwt.GWTClass. Of course, the number of instances should be fairly stable between refreshes.

              • 4. Re: possible memory leak in dev mode with errai
                mojoo mojoo Newbie

                hello i had a quick look into some dumps and it seams like its mostly instances from class org.jboss.errai.codegen.meta.impl.java.JavaReflectionClass growning:

                startup:              org.jboss.errai.codegen.meta.impl.java.JavaReflectionClass -- > Number of Objects: 2.244 | Used Heap Size: 233.376 | Retained Heap Size: 990.732.528

                after 1st refresh:  org.jboss.errai.codegen.meta.impl.java.JavaReflectionClass -- > Number of Objects: 3.380 | Used Heap Size: 351.520 | Retained Heap Size: 1.964.939.208

                • 5. Re: possible memory leak in dev mode with errai
                  Christian Sadilek Master

                  ok that's interesting but  ~3000 JavaReflectionClass instances only consume about 0.3% of the heap in my case. so, there must be something else involved.  if I perform a GC after a DevMode refresh and before I produce a new heapdump, the JavaReflectionClass instance count stays stable (using the latest snapshots and after the first refresh).  does the instance count keep growing in your app?

                   

                  cheers,

                  christian

                  1 of 1 people found this helpful
                  • 6. Re: possible memory leak in dev mode with errai
                    mojoo mojoo Newbie

                    hello again,

                    i made a mistake in my measurements. i dumped the heaps without calling the gc first. i run the tests again with this setup:

                     

                    start codeserver

                    wait for load

                    call gc via jconsole

                    take dump

                    hit reload

                    wait for load

                    call gc via jconsole

                    take dump

                    and so on

                     

                    the results are different now. i cant see an increase of JavaReflectionClass instance after the 2nd refresh. biggest increase i found in the Accumulated Objects by Class report was:

                     

                    -------------------------------------------------------------------------------------------------

                    0 refresh

                    java.lang.Class --> Number of Objects: 5.959 Used Heap Size:  27.944 Retained Heap Size:    9.126.632

                    Class Name org.jboss.errai.codegen.literal.LiteralFactory @ 0x761b00d80 | Retained Heap 267.128

                    -------------------------------------------------------------------------------------------------

                    1 refresh

                    java.lang.Class --> Number of Objects: 5.980 Used Heap Size:  27.944 Retained Heap Size:    9.363.936

                    Class Name org.jboss.errai.codegen.literal.LiteralFactory @ 0x761b00c38 |  Retained Heap 356.280

                    -------------------------------------------------------------------------------------------------

                    2 refresh

                    java.lang.Class --> Number of Objects: 5.981 Used Heap Size:  27.944 Retained Heap Size:   74.187.008

                    Class Name org.jboss.errai.codegen.literal.LiteralFactory @ 0x761b00c38 | Retained Heap 65.069.384

                    -------------------------------------------------------------------------------------------------

                    3 refresh

                    java.lang.Class --> Number of Objects: 5.982 Used Heap Size:  27.944 Retained Heap Size:  139.026.888

                    Class Name org.jboss.errai.codegen.literal.LiteralFactory @ 0x761b00c38 | Retained Heap 129.798.872

                    -------------------------------------------------------------------------------------------------

                    note that i cut down the project to about 10% of the original size to get the dumps.

                    hope i got it right this time. thanks again. if you need any other information please let me know.

                    • 7. Re: possible memory leak in dev mode with errai
                      Christian Sadilek Master

                      Hi,

                       

                      Thanks for following up!

                       

                      This looks exactly like the problem we fixed in the latest 2.2.0-SNAPSHOTs. Are you sure the jars got updated? The LiteralFactory is holding a literal cache that should not be growing between refreshes. I just tested this and could not reproduce it.

                       

                      If you can reproduce this with the latest snapshots, could you take a look at the LITERAL_CACHE and see if the number of items in the cache  increases and what these values are? You could  add a breakpoint in the emtpyCache method in org.jboss.errai.codegen.literal.LiteralFactory to investigate this (this method should be called during every refresh). That would be of enormous help to track down the problem.

                       

                      Thanks,

                      Christian

                      • 8. Re: possible memory leak in dev mode with errai
                        mojoo mojoo Newbie

                        sorry, i got mixed up in my jars a little :/  looks like the shapshot fixes this and improves the memory footprint a lot. thanks again.

                        • 9. Re: possible memory leak in dev mode with errai
                          Christian Sadilek Master

                          That's really good news. Thanks for all the feedback!