Alpakka JMS Consumer memory leak
arcavire opened this issue · comments
Versions used
Akka version: 2.6.18
Alpakka version: 4.0.0
Scala version: 2.13
IBM MQ AllClient version: 9.3.4.0
Expected Behavior
akka.stream.alpakka.jms.impl.JmsConsumerSession
not accumulating in memory
Actual Behavior
akka.stream.alpakka.jms.impl.JmsConsumerSession
are accumulating in memory because they are still referenced from jmsListener
Observations
At the begging the consumer sessions are added to a list (jmsSessions
) in akka.stream.alpakka.jms.impl.JmsConnector#onSession
. Additionally, it is referenced by anonymous jms.MessageListener created in akka.stream.alpakka.jms.impl.JmsTxSourceStageLogic
.
Then I restart the MQ and akka.stream.alpakka.jms.impl.JmsConnector#handleRetriableException
is called. That method cleans the list of the sessions, but they are still referenced from the listeners:
Then the MQ is back and new sessions are added to the list, but the old ones are still kept in memory and will never be garbage collected. The number of the sessions kept in memory grows with each connection lost with MQ.
Reproducible Test Case
- Start an application with JmsConsumer.txSource that reads from MQ.
- Restart the MQ.
Thank you for your analysis of this problem.
Fixed with
Thank you