If we run the code below and inspect the JVM with a profiler, it looks
as if there's a memory leak in the MQ JmsProducer code. Every new
Producer instantiates a new MQJMSMessage, but as time goes by, more and
more of these objects are being allocated in memory. Forcing a garbage
collect (either from jconsole or by lowering the heap space) doesn't
impact the number of allocated objects. Is it illegal to send multiple
messages from the same Producer? Is there a way to avoid caching
messages inside the Producer/Session in WebSphere MQ?

This is just a test to reproduce a problem in our production
environment, where we use a Spring DefaultMessageListenerContainer to
receive message and send response messages to another queue with the
same Session object. We experience the memory leak if we set the cache
level to anything beyond CACHE_CONNECTION. Doesn't WebSphere MQ support
using a higher cache level in this scenario or is there something we can
do to flush messages from a cache somewhere after sending?

Thank you for any help,


-- code snippet --
MQConnectionFactory factory = new MQConnectionFactory();
factory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_T CPIP);

Connection connection = factory.createConnection("", "");
Session session = connection.createSession(false, AUTO_ACKNOWLEDGE);
Queue queue = session.createQueue("MY.OWN.QUEUE");

while (true) {
MessageProducer sender = session.createProducer(queue);
TextMessage message = session.createTextMessage(data);