You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by pe...@apache.org on 2021/12/11 12:23:40 UTC

[pulsar] 08/10: [Broker] Call .release() when discarding entry to prevent direct memory leak (#11748)

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

penghui pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/pulsar.git

commit b9d4383fdd9ead429ba065cb1e1763d0ba0116bb
Author: Lari Hotari <lh...@users.noreply.github.com>
AuthorDate: Mon Aug 23 21:15:51 2021 +0300

    [Broker] Call .release() when discarding entry to prevent direct memory leak (#11748)
    
    (cherry picked from commit 7906bb5990a918adfc47ed0ab52063caabac2801)
---
 .../service/persistent/PersistentDispatcherSingleActiveConsumer.java    | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java
index 5904c96..00b549d 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java
@@ -224,7 +224,9 @@ public final class PersistentDispatcherSingleActiveConsumer extends AbstractDisp
                 Entry entry = iterator.next();
                 byte[] key = peekStickyKey(entry.getDataBuffer());
                 Consumer consumer = stickyKeyConsumerSelector.select(key);
+                // Skip the entry if it's not for current active consumer.
                 if (consumer == null || currentConsumer != consumer) {
+                    entry.release();
                     iterator.remove();
                 }
             }