Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-3588

PooledSession - Can cause memory leak in case many consumers is created by the session

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • None
    • 5.6.0
    • Camel

    Description

      See (CAMEL-4657

      In the activemq-pool we have a memory leak when a PooledSession is used to create many consumers. As each consumer is added to an internal list, which in case the session is closed, the list is used to ensure all previously created consumers gets closed as well.

      However if the session is used to create many consumers, then that internal list just keep growing, and causing OOME. See attached screenshots of a before vs after with the bug fix.

      So to remedy this situation, we should ensure any closed consumer gets removed from that internal list. As its already closed, and therefore the session do not need to keep track of it anymore.

      This bug have existed ever since AMQ-615.

      The impact of this bug can be seen in CAMEL-4657, which essentially makes using Camel for request/reply over JMS with AMQ and with named replyTo queues (eg not temporary) will cause this problem. The problem manifests due Spring DMLC, which uses a MessageSelector to only pickup expected reply messages. And because the MessageSelector is created once when the consumer is created. We need to create a new Consumer, every time a new message is doing request/reply, to ensure the Message Selector gets updated. So in that situation many consumers get created, which leads to OOME as the list in PooledSession keeps growing.

      It would be great if this bug fix can be backported to the 5.5 branch as well.

      Attachments

        1. AMQ-3588.patch
          5 kB
          Claus Ibsen
        2. after.png
          74 kB
          Claus Ibsen
        3. before.png
          60 kB
          Claus Ibsen

        Issue Links

          Activity

            People

              davsclaus Claus Ibsen
              davsclaus Claus Ibsen
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: