2 Replies Latest reply on Jul 24, 2007 9:58 AM by zooxmusic

    OutOfMemory because of too many threads and not sure what to

    zooxmusic

      Hi all,

      I have a problem that I am not quite sure how to solve and if it is something obvious please accept my apology early.

      We are using durable topic JMS clients on a wireless network that drops out periodically and because of this they do not close all connections/threads gracefully

      when we try to reconnect we get "Client Id is already registered" as we should

      the problem is that every time this client tries to connect even though they receive this exception it is still creating 4 threads per occurrence.

      with 180 clients quite a few have over 300 threads allocated to them and they still aren't connected which drops JBoss once we run out of memory


      What can I do?

      Is there anyway to detect a broken connection on the server side and kill the threads?

      I am almost thinking that this architecture doesn't fit what we need to do since they do drop out and we definitely need a durable topic.


      Brian

        • 1. Re: OutOfMemory because of too many threads and not sure wha

           

          "zooxmusic" wrote:

          Is there anyway to detect a broken connection on the server side and kill the threads?


          The server already does this. It disconnects clients that have stopped pinging
          after 2 minutes (See "Read Timeout" in uil2-service.xml).

          Most likely you've not closed the connection after you got "client id" error message
          so it is still open and pinging the server.

          It's one of the common errors, the initialization code should look like this:

          Connection c = connectionFactory.createConnection(...);
          try
          {
           c.setClientId(x);
          }
          catch (JMSException e)
          {
           // Failed to initialize (close the connection!)
           try
           {
           c.close();
           }
           catch (JMSException ignored) {}
           throw e;
          }
          


          Of course, you could wait until the client side VM does a full GC,
          but by then you've probably got hundreds of open connections lying around.

          It's never a good idea to leave resource intensive objects to be closed by
          the garbage collector.

          • 2. Re: OutOfMemory because of too many threads and not sure wha
            zooxmusic

            Thanks Adrian, that was it.

            Brian