Skip to content

Commit

Permalink
Correctly manage buffer life-cycle in http2 multiplex example
Browse files Browse the repository at this point in the history
Motivation:

We not correctly managed the life-cycle of the buffer / frames in our http2 multiplex example which lead to a memory leak.

Modifications:

- Correctly release frame if not echo'ed back the remote peer.
- Not retain content before echo back to remote peer.

Result:

No more leak in the example, fixes [netty#6636].
  • Loading branch information
normanmaurer committed Apr 19, 2017
1 parent a0fcb72 commit 38483e8
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
*/
public void onDataRead(ChannelHandlerContext ctx, Http2DataFrame data) throws Exception {
if (data.isEndStream()) {
sendResponse(ctx, data.content().retain());
sendResponse(ctx, data.content());
} else {
// We do not send back the response to the remote-peer, so we need to release it.
data.release();
}
}

Expand Down

0 comments on commit 38483e8

Please sign in to comment.