1 Reply Latest reply on Oct 29, 2003 3:27 PM by Adrian Brock

    JMS memory leak

    matt.preston Newbie

      I have a weird JMS problem where after sending n messages to a Topic I get an OutOfMemoryError. I noticed this problem using jboss 3.2.1 using the JVM InvocationLayer.

      My publisher looks like:

      ============================

      topicConnectionFactory = (TopicConnectionFactory) jndiContext.lookup("jvm_ConnectionFactory");
      topic = (Topic) jndiContext.lookup("Topic");

      topicConnection = topicConnectionFactory.createTopicConnection();

      topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
      topicPublisher = topicSession.createPublisher(topic);

      topicPublisher.setTimeToLive(10L * 60L * 1000L);
      objectMessage = topicSession.createObjectMessage();

      topicConnection.start();

      ============================

      Then I make multiple calls to :

      objectMessage.setObject(anEvent);
      topicPublisher.publish(objectMessage);

      When profiling the memory usage of my application, I noticed that for every call to topicPublisher.publish() I get a new instance of JVMClientIL & JVMClientILService created.

      after sending 10,000 messages I have 10,000 of these Objects in memory. After sending ~60,000 message the VM blows up with an OutOfMemoryError (max heap set to 128mb).

      It doesn't seem to matter whether I attach a Subscriber to the Topic or not, the same thing still happens.

      I'm a bit of a JMS novice, so I can't see if the problem lies in the way I am using/configuring JMS, or in the implementation - I suspect it's my fault... Does anyone have any idea why this may be happening?

      Thanks a lot,
      Matt Preston