From: Robert Varga Date: Thu, 28 May 2015 22:20:39 +0000 (+0200) Subject: Release OutboundQueueEntry callback on completion X-Git-Tag: release/beryllium~44 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=f05d7a5b91980627e3e19ac88352813eb5afec10;p=openflowjava.git 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 (cherry picked from commit 6b6700b60e2db29fdb23d2044ab254accf86ecc9) --- 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); } } - }