From 7f606a469023b8422ec4f3da4a55a7ddf7363d1f Mon Sep 17 00:00:00 2001 From: huaishk Date: Mon, 5 Mar 2018 17:32:29 +0800 Subject: [PATCH] ARTEMIS-1728 Reclaim memory when page cursor complete Free hash set used to hold page position for acks and removed refs. The two set is cleared, but they still hold a big array. It is safe to replace the old one with empty set. --- .../core/paging/cursor/impl/PageSubscriptionImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java index d970f8aca4..a767c09d01 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/paging/cursor/impl/PageSubscriptionImpl.java @@ -334,7 +334,9 @@ final class PageSubscriptionImpl implements PageSubscription { } infoPG.acks.clear(); + infoPG.acks = Collections.synchronizedSet(new LinkedHashSet()); infoPG.removedReferences.clear(); + infoPG.removedReferences = new ConcurrentHashSet<>(); } tx.addOperation(new TransactionOperationAbstract() { @@ -901,11 +903,11 @@ final class PageSubscriptionImpl implements PageSubscription { private final long pageId; // Confirmed ACKs on this page - private final Set acks = Collections.synchronizedSet(new LinkedHashSet()); + private Set acks = Collections.synchronizedSet(new LinkedHashSet()); private WeakReference cache; - private final Set removedReferences = new ConcurrentHashSet<>(); + private Set removedReferences = new ConcurrentHashSet<>(); // The page was live at the time of the creation private final boolean wasLive;