activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cwash <chris.w...@gmail.com>
Subject Number of PooledConnection and PooledConnection$1 instances in heap growing linearly with produced messages and not cleaned up
Date Mon, 23 Jul 2012 16:39:00 GMT
I'm seeing an issue activemq-pool's PooledConnectionFactory, with a pretty
simple test case of producing messages.  Within my client, the underlying
pool appears as though it is not cleaning up some objects under the
PooledConnection class correctly.  I'm seeing the following classes grow at
the top of my Heap Histogram in JVisualVM.

Class, Instances (%), Size (%)
java.util.concurrent.locks.ReentrantLock$NonfairSync, 314153 (19.7%),
13822732 (27.9%)
java.lang.Object[], 314020 (19.7%), 6326656 (12.8%)
java.util.concurrent.locks.ReentrantLock, 313209 (19.6%), 7517016 (15.2%)
java.util.concurrent.CopyOnWriteArrayList, 313183 (19.6%), 10021856 (20.2%)
org.apache.activemq.pool.PooledConnection, 156562 (9.8%), 6419042 (13%)
org.apache.activemq.pool.PooledConnection$1, 156562 (9.8%), 357488 (7.6%)

Everything else is sub 1% of heap.

My connection factory is set up like this:

connectionFactory = new ActiveMQConnectionFactory(
                    userId,
                    passWord,
                    brokerURL);

            RedeliveryPolicy policy =
connectionFactory.getRedeliveryPolicy();

            int reDeliveryDelay =
Integer.parseInt(props.getProperty("xcal.mbus.InitialReDeliveryDelay"));
            int maxReDeliveryCount =
Integer.parseInt(props.getProperty("xcal.mbus.MaxReDelivery"));
            policy.setInitialRedeliveryDelay(reDeliveryDelay);
            policy.setMaximumRedeliveries(maxReDeliveryCount);
            policy.setBackOffMultiplier(2);
            policy.setUseExponentialBackOff(true);
producerConnectionFactory = new PooledConnectionFactory(connectionFactory);
            producerConnectionFactory.start();

And used like this:

public TextMessage sendTextMessage(String destinationType, String
destinationName, String message) throws JMSException  {
        TextMessage m = null;
        Connection connection=null;
        MessageProducer producer=null;
        Session session=null;
        try{
            connection = producerConnectionFactory.createConnection();
            session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
            producer = session.createProducer(null);
            Destination destination=null;
            if ( "QUEUE".equalsIgnoreCase(destinationType) ){
                destination = session.createQueue(destinationName);
            }else if ("TOPIC".equalsIgnoreCase(destinationType)){
                destination = session.createTopic(destinationName);
            }
            m = session.createTextMessage(message);
            producer.send(destination, m, DeliveryMode.PERSISTENT,
producer.getPriority(),0L);
        }catch(JMSException e){
            log.error( "Received exception in sendTextMessage: " +
e.getMessage());
            throw e;
        }finally {
            try{
                if( producer != null ) producer.close();
            }catch(JMSException jmsexp1){
            }
            try {
                if (session != null) session.close();
            }catch(JMSException jmsexp2) {
            }
            try{
                if (connection != null) connection.close();
            }catch(JMSException jmsexp3){
            }
        }
        return m;
    }

To test, if I just call this in a while loop I notice the connectionPool
seems to grow, creating new instances that all seem to point to the same
spot

Object[]
CopyOnWriteArrayList
PooledConnection
PooledConnection$1
Object[]
CopyOnWriteArrayList
PooledSession 
** tempDestEventListeners **



Any thoughts?




--
View this message in context: http://activemq.2283324.n4.nabble.com/Number-of-PooledConnection-and-PooledConnection-1-instances-in-heap-growing-linearly-with-produced-mp-tp4654265.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message