1 Reply Latest reply on Apr 27, 2005 1:14 AM by zboris

    Timer.cancel() leaves timer thread live and running

    zboris

      I've seen similar post somewhere in this forum, but no answer was given.

      Please let me clarify. During life cycle of Jboss (time between restarts) I have to create at least 10000 timers within my application. 99% (at least) of this timers are getting cancelled, so simultaneuosly I have around only 20 of them running.

      The problem is that after creating say 3000 timers - JBoss reports: java.lang.OutOfMemoryError: unable to create new native thread.

      I have done similar investigation as this dude in post: http://www.jboss.org/index.html?module=bb&op=viewtopic&t=63046

      and it seems to be right that jboss leaves threads running after they have been cancelled. Any clarification on this?

      I am running Jboss 4.0.1sp1 under SUSE linux enterprise 3.1 SDK 1.4.2_02.

      Thanks, Josif Amar-din

        • 1. Re: Timer.cancel() leaves timer thread live and running
          zboris

          To make sure that spawning of a new Timers and then cancelling them do not result in thread's pool growing in its size mark the cancelTimer method's transaction in ejb-jar.xml as NotSupported. i.e.:

          <container-transaction>

          <ejb-name>MyEnterpriseBean</ejb-name>
          <method-name>*</method-name>

          <trans-attribute>Required</trans-attribute>
          </container-transaction>

          <container-transaction>

          <ejb-name>MyEnterpriseBean</ejb-name>
          <method-name>cancelTimer</method-name>

          <trans-attribute>NotSupported</trans-attribute>
          </container-transaction>