From 08a36bc8407c878f332c6e2206febfe431c2f999 Mon Sep 17 00:00:00 2001 From: Jason Hoetger Date: Sun, 26 Feb 2017 12:06:26 -0800 Subject: [PATCH] Fixing memory leak on initial request when HttpObjectAggregator is enabled --- .../littleshoot/proxy/impl/ProxyToServerConnection.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/littleshoot/proxy/impl/ProxyToServerConnection.java b/src/main/java/org/littleshoot/proxy/impl/ProxyToServerConnection.java index b1c661efb..b8d270fd4 100644 --- a/src/main/java/org/littleshoot/proxy/impl/ProxyToServerConnection.java +++ b/src/main/java/org/littleshoot/proxy/impl/ProxyToServerConnection.java @@ -930,6 +930,13 @@ void connectionSucceeded(boolean shouldForwardInitialRequest) { } else { LOG.debug("Dropping initial request: {}", initialRequest); } + + // we're now done with the initialRequest: it's either been forwarded to the upstream server (HTTP requests), or + // completely dropped (HTTPS CONNECTs). if the initialRequest is reference counted (typically because the HttpObjectAggregator is in + // the pipeline to generate FullHttpRequests), we need to manually release it to avoid a memory leak. + if (initialRequest instanceof ReferenceCounted) { + ((ReferenceCounted)initialRequest).release(); + } } /**