6 Replies Latest reply on Aug 11, 2003 8:05 AM by pants

    OutOfMemoryError

    pants Newbie

      After deploying some EJB's to JBoss a number of times JBoss will stop with an OutOfMemoryError. Profiling JBoss reveals that its not unloading classes, so eventually you run out of memory.

      Any ideas on how to get JBoss to unload classes?

        • 1. Re: OutOfMemoryError
          Adrian Brock Master

          Don't keep hold of class references in your code.

          Typically, these are in supporting jars, usually
          in static HashMaps.

          I've heard struts 1.0 had this problem and I was
          also speaking with somebody recently who had
          a similar problem with hibernate.

          Regards,
          Adrian

          • 2. Re: OutOfMemoryError
            pants Newbie

            What exactly do you mean by "holding references". Do you mean just set the variable to null?

            What do you do with static variables?

            Do you use an explicit close or dispose method?

            • 3. Re: OutOfMemoryError
              Adrian Brock Master

              No, the supporting jar is not in the deployment.
              It has something like:

              static HashMap map = new HashMap();

              somewhere it will do
              map.put(anObjectFromDeployment);

              but never remove it.

              Regards,
              Adrian

              • 4. Re: OutOfMemoryError
                pants Newbie

                I've tried just using an empty mbean in the default jboss server. The mbean is two classes and simply has a start and a stop method. The two methods are empty.

                Each time I redeploy this mbean the previous instances are not unloaded. If I profile the application in OptimizeIt it shows lots of versions of the mbean classes loaded in the VM with one instance of the latest version allocated.

                JBoss is not unloading classes. Is there a way to fix this?

                • 5. Re: OutOfMemoryError
                  Amit Kirdatt Newbie

                  have tried increasing the stack size?

                  you can do this by using "-mx512m" for 512M of RAM at the java command line

                  • 6. Re: OutOfMemoryError
                    pants Newbie

                    Ummm, what happens when the memory used exceeds the 512M stack. Set the stack to 1024Mb? What if it goes beyond that? I'm not sure this is a solution.