Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpakka JMS Consumer memory leak #3038

Closed
arcavire opened this issue Nov 20, 2023 · 4 comments
Closed

Alpakka JMS Consumer memory leak #3038

arcavire opened this issue Nov 20, 2023 · 4 comments
Milestone

Comments

@arcavire
Copy link

arcavire commented Nov 20, 2023

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.
@arcavire arcavire changed the title Alpakka JMS Consumer connection leak Alpakka JMS Consumer memory leak Nov 20, 2023
@ennru ennru added the p:jms label Nov 22, 2023
@ennru
Copy link
Member

ennru commented Nov 22, 2023

Thank you for your analysis of this problem.

@ennru
Copy link
Member

ennru commented Nov 29, 2023

@ennru ennru closed this as completed Nov 29, 2023
@arcavire
Copy link
Author

Thank you

@patriknw patriknw added this to the 7.0.1 milestone Dec 1, 2023
@arcavire
Copy link
Author

arcavire commented Dec 6, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants