4 Replies Latest reply on Aug 18, 2010 6:51 AM by jaikiran pai

    Memory leak in StatelessBeanContext

    Wessel van Norel Newbie

      Our application starts a service (org.jboss.ejb3.annotation.Service) which uses java.util.TimerTask to start jobs.

       

      These jobs are Stateless EJB's. Within the run method of the timer that is triggered we use InitialContext.doLookup("JNDI_NAME"); to lookup these EJB's and execute a method on them. Now unfortunately once the EJB is done processing, it's not removed from memory, so after a few days our application runs out of heap space.The objects that are created in the run method to be passed as a parameter to the EJB are not kept in memory.

       

      The objects that are growing during time (according to eclipse MAT) are the StatelessContainers, and specific the ThreadLocalPool pool variable in them.These keep the link towards the EJB's which are started from the timers.

       

      We are wondering why the StatelessContainers keep our EJB's in their pool, even though they are done processing (according to us). And we are mostly interested in how to solve this memory leak, since restarting our application server ever few days is not really an option.

       

      Removing for example JTA (and all logic besides a log statement) from the EJB's doesn't help, they are still kept in memory. Also when we use EJB timers (@javax.ejb.Timeout) to start the EJB's we get the same result.

       

       

      We are using: JBossAS 5.1.0, sun jdk 1.6.0_17 with -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled