This is an automated email from the ASF dual-hosted git repository.

cshannon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq.git

commit d1e9ba68b3cbea3e9294cf4993d005c3c8ea86f2
Author: Artur Pedroso <[email protected]>
AuthorDate: Tue Feb 22 22:10:50 2022 +0000

    AMQ-8509: Fix TempUsage memory leak
    
    If you have an application that creates lots of queues it will eventually
    fail with OOM because TempUsage is started on Queue#start but never stopped.
    
    The `systemUsage.getTempUsage().start()` used on the Queue#start
    adds elements on a List from TempUsage parent and these elements
    are never removed.
    
    To reproduce this issue you need to leave an application
    running for a long time creating different queues.
    
    The only way to avoid the leak right now is to stop the BrokerService,
    which isn't a solution.
---
 .../src/main/java/org/apache/activemq/broker/region/Queue.java         | 3 +++
 1 file changed, 3 insertions(+)

diff --git 
a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java 
b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
index 9e01609..20f8a3a 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/region/Queue.java
@@ -1064,6 +1064,9 @@ public class Queue extends BaseDestination implements 
Task, UsageListener, Index
             if (systemUsage.getStoreUsage() != null) {
                 systemUsage.getStoreUsage().stop();
             }
+            if (this.systemUsage.getTempUsage() != null) {
+                this.systemUsage.getTempUsage().stop();
+            }
             if (store != null) {
                 store.stop();
             }

Reply via email to