From 6b6700b60e2db29fdb23d2044ab254accf86ecc9 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 29 May 2015 00:20:39 +0200 Subject: [PATCH] Release OutboundQueueEntry callback on completion Memory traces of steady state with mininet have shown we are retaining already-completed callbacks for the duration of the OutboundQueueImpl's generation. For multipart requests that means we end up holding up large chunks of memory for extended time, leading to unacceptable memory pressure which can be easily avoided. Change-Id: I2a980fc454583e8fb5d7fe44e47d7ddf076c650b Signed-off-by: Robert Varga --- .../protocol/impl/core/connection/OutboundQueueEntry.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java index 48722dbb..4b8820bd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java @@ -77,6 +77,10 @@ final class OutboundQueueEntry { completed = reallyComplete; if (callback != null) { callback.onSuccess(response); + if (reallyComplete) { + // We will not need the callback anymore, make sure it can be GC'd + callback = null; + } } LOG.debug("Entry {} completed {} with response {}", this, completed, response); return reallyComplete; @@ -87,10 +91,10 @@ final class OutboundQueueEntry { completed = true; if (callback != null) { callback.onFailure(cause); + callback = null; } } else { LOG.warn("Ignoring failure {} for completed message", cause); } } - } -- 2.36.6