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

Memory leak in ConnectionStateTracker with MessagePull objects

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.4.2, 5.5.0
    • 5.6.0
    • None
    • None
    • Patch Available

    Description

      We discovered a memory leak in ConnectionStateTracker in case a long-lived connection with prefetch=0 is used.

      If prefetch=0 is used, MessagePull objects are enqueued in messageCache with an estimated size of 400. But in the cache's removeEldestEntry() method no size is subtracted from currentCacheSize for MessagePull instances. This messes with the cache as it will continue to remove objects even if there is space in the cache. But after about 5,368,709 consumed messages this will cause the currentCacheSize to roll-over maximum integer and become negative. As a consequence, for the next about 5,368,709 no messages will be removed from the cache any longer.

      This sooner or later will trigger out-of-memory conditions, depending on the size of the various pools. In our case this caused out-of-memory in PermGen first, as message IDs seem to be internalized, and PermGen is considerably smaller than the heap.

      Attachments

        1. connectionstatetracker_fixed.patch
          0.9 kB
          Martin Carpella

        Issue Links

          Activity

            People

              gtully Gary Tully
              mcarpella Martin Carpella
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: