Release OutboundQueueEntry callback on completion 79/21379/1
authorRobert Varga <rovarga@cisco.com>
Thu, 28 May 2015 22:20:39 +0000 (00:20 +0200)
committerRobert Varga <rovarga@cisco.com>
Thu, 28 May 2015 22:20:39 +0000 (00:20 +0200)
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 <rovarga@cisco.com>
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java

index 48722dbbdd3d0db856fa83af27953b1e2dcc3e6a..4b8820bd9b430317e7dd4a6b0ddd6d65d091e0ea 100644 (file)
@@ -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);
         }
     }
-
 }