activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hiram Chirino" <hi...@hiramchirino.com>
Subject Re: Memory Leak in ActiveMQConnection/ActiveMQConnectionFactory when broker is down
Date Wed, 06 Jun 2007 21:33:39 GMT
I think this has been fixed in 4.1.1.. are you using something older?

On 6/1/07, Topher Johnson <topher.johnson@blastradius.com> wrote:
>
> When we attempt to create a connection and our broker is down, we
> continuously attempt to reconnect.  This causes repeated calls to
> createActiveMQConnection in the ActiveMQConnectionFactory class, which in
> turn creates a new ActiveMQConnection object.
>
> The constructor of this object adds a reference of itself to a collection
> called factoryStats.  When the exception is thrown because the broker cannot
> be found the reference to the connection object in the factoryStats object
> is not removed which causes a memory leak.
>
> Our fix for this was to add some lines to the catch blocks in the
> createActiveMQConnection(String, String) method in ActiveMQConnectionFactory
> that will remove the reference to the connection object from the
> factoryStats object (Our additions/changes are in bold):
>
> ----------------
>
> protected ActiveMQConnection createActiveMQConnection(String userName,
> String password) throws JMSException {
>         if (brokerURL == null) {
>             throw new ConfigurationException("brokerURL not set.");
>         }
>         Transport transport;
>         ActiveMQConnection connection = null;
>         try {
>             transport = createTransport();
>             connection = createActiveMQConnection(transport, factoryStats);
>
>             connection.setUserName(userName);
>             ...
>             connection.setRedeliveryPolicy(getRedeliveryPolicy());
>
>             transport.start();
>
>             if( clientID !=null )
>                 connection.setClientID(clientID);
>
>             return connection;
>         }
>         catch (JMSException e) {
>             if(factoryStats != null)
>                  factoryStats.removeConnection(connection);
>             throw e;
>         }
>         catch (Exception e) {
>              if(factoryStats != null)
>                  factoryStats.removeConnection(connection);
>              throw JMSExceptionSupport.create("Could not connect to broker
> URL: " + brokerURL + ". Reason: " + e, e);
>         }
>     }
> --
> View this message in context: http://www.nabble.com/Memory-Leak-in-ActiveMQConnection-ActiveMQConnectionFactory-when-broker-is-down-tf3853937s2354.html#a10918646
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>
>


-- 
Regards,
Hiram

Blog: http://hiramchirino.com

Mime
View raw message