You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by cwash <ch...@gmail.com> on 2012/07/23 18:39:00 UTC

Number of PooledConnection and PooledConnection$1 instances in heap growing linearly with produced messages and not cleaned up

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.

Re: Number of PooledConnection and PooledConnection$1 instances in heap growing linearly with produced messages and not cleaned up

Posted by cwash <ch...@gmail.com>.
Gaurav Sharma wrote
> 
> I think you forgot to do: connection.start();
> 

Hey Gaurav, thanks for the suggestion.  I think the PooledConnectionFactory
takes care of calling connection#start() for you.  Have a look at the source
to 
http://activemq.apache.org/maven/5.6.0/activemq-pool/apidocs/org/apache/activemq/pool/ConnectionPool.html#start()
http://activemq.apache.org/maven/5.6.0/activemq-pool/apidocs/org/apache/activemq/pool/ConnectionPool.html#start() 


Gaurav Sharma wrote
> 
> Also, I have the pool size configured on the pooledconnectionfactory via
> setMaxConnections() and setMaximumActive() for tighter control.
> 

I have those set as well through configuration, but removed so as to
simplify.



--
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-tp4654265p4654500.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Number of PooledConnection and PooledConnection$1 instances in heap growing linearly with produced messages and not cleaned up

Posted by Gaurav Sharma <ga...@gmail.com>.
I think you forgot to do: connection.start();
Also, I have the pool size configured on the pooledconnectionfactory via
setMaxConnections() and setMaximumActive() for tighter control.

On Mon, Jul 23, 2012 at 9:43 AM, cwash <ch...@gmail.com> wrote:

> BTW, using version 5.6
>
>
>
> --
> 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-tp4654265p4654266.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

Re: Number of PooledConnection and PooledConnection$1 instances in heap growing linearly with produced messages and not cleaned up

Posted by cwash <ch...@gmail.com>.
BTW, using version 5.6



--
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-tp4654265p4654266.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.