Ok, a few things to report. The call to rt.gc() in ClientServlet really slowed things down, so I removed it.
I then noticed that memory became exhausted (500MB) in a few minutes. I also managed to replicate this using a simple self contained jms program (using no EJBs) which simply sends messages to a queue, which are then picked up by a message listener and sent on to a topic where they are consumed by two subscribers with selectors, exactly the same as your example but using straightforward jms - no ejbs. Looking more closely at your code and noticed the cause of the leak: in PlexMDB, when the message is received it sends 4 more messages to the topic: | ObjectMessage reply = session.createObjectMessage(); | reply.setStringProperty("target", "10"); | reply.setIntProperty("cnt", cnt); | reply.setObject(payload); | producer.send(reply); | reply = session.createObjectMessage(); | reply.setStringProperty("target", "20"); | reply.setIntProperty("cnt", cnt); | reply.setObject(payload); | producer.send(reply); | reply = session.createObjectMessage(); | reply.setStringProperty("target", "30"); | reply.setIntProperty("cnt", cnt); | reply.setObject(payload); | producer.send(reply); | reply = session.createObjectMessage(); | reply.setStringProperty("target", "40"); | reply.setIntProperty("cnt", cnt); | reply.setObject(payload); | In ClientServlet after sending a message the thread synchronously waits to receive two messages - one from each consumer, before continuing and sending the next message. However, the consumers should receive 2 messages *each* since the selector matches target = 10 OR target = 20. Therefore the code should be changed to receive four message not two: | log.info("Message "+i+"/"+count+" was successfully sent to the " + queue.getQueueName() + " queue"); | | message = (ObjectMessage) consumer1.receive(); | ArrayList v1 = (ArrayList) message.getObject(); | | message = (ObjectMessage) consumer2.receive(); | ArrayList v2 = (ArrayList) message.getObject(); | | message = (ObjectMessage) consumer1.receive(); | v1 = (ArrayList) message.getObject(); | | message = (ObjectMessage) consumer2.receive(); | v2 = (ArrayList) message.getObject(); | | log.info("Received messages, size: " + (v1.size() + v2.size())); | Before contining to send the next message. Because the original code was only waiting to receive two messages, then the sends were executing faster than messages were being consumed and eventually memory would get exhausted since messages were building up on the subscriptions. When I change the code to wait for four messages, I can run my test program for extended periods without exhausting memory. I shall now try running it on my test box for several hours to make sure, but I think this is the problem. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3952331#3952331 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3952331 _______________________________________________ JBoss-user mailing list JBoss-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jboss-user