activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mers <>
Subject Memory leak in ActiveMQConnectionFactory.
Date Fri, 26 Jan 2007 16:16:48 GMT


We're using ActiveMQ 4.1.0. We have code that periodically calls
ActiveMQConnectionFactory.createConnection() to try to reestablish a
connection when a broker fails. After some time, we were getting a heap
overflow if the broker does not come up.

We narrowed down the problem and can replicate it with the following code:

import org.apache.activemq.ActiveMQConnectionFactory;

import javax.jms.Connection;
import javax.jms.JMSException;

public class TestJMS {

	private ActiveMQConnectionFactory  connectionFactory;
	public static void main(String[] args)
			throws InterruptedException {
		TestJMS testJMS = new TestJMS();

	private void start()
			throws InterruptedException {

		Connection  connection = null;

		connectionFactory = new ActiveMQConnectionFactory();

		while (true) {
			try {
				connection = connectionFactory.createConnection();
				System.out.println("connection succeeded");
			catch (JMSException e) {
				System.out.println("connection failed.");
				connection = null;

Analysing the heap, the number of "class
[Lorg.apache.activemq.command.DataStructure;" grows by 1 for each failed
createConnection() call. This 65KB object is an array of nulls, and is
referenced by

"References to this object:
org.apache.activemq.openwire.OpenWireFormat@0x259f4b88 (53 bytes) : field

Please reply if there's a way around this. Right now we'll have to create a
new connectionFactory each time.

View this message in context:
Sent from the ActiveMQ - Dev mailing list archive at

View raw message