akka / alpakka

Alpakka is a Reactive Enterprise Integration library for Java and Scala, based on Reactive Streams and Akka.

Home Page:https://doc.akka.io/docs/alpakka/current/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alpakka JMS Consumer memory leak

arcavire opened this issue · comments

commented

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.
image

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:
image

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

  1. Start an application with JmsConsumer.txSource that reads from MQ.
  2. Restart the MQ.

Thank you for your analysis of this problem.

Fixed with

commented

Thank you

commented

@ennru, would it be possible to backport the fix to 4.0? This is the last version with Apache 2.0 license.