Skip to content

Commit

Permalink
RATIS-2197. Clean remote stream to resolve direct memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
symious committed Nov 21, 2024
1 parent 06affdf commit d2b563e
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,13 @@ static void sendDataStreamException(Throwable throwable, DataStreamRequestByteBu
void cleanUp(Set<ClientInvocationId> ids) {
for (ClientInvocationId clientInvocationId : ids) {
Optional.ofNullable(streams.remove(clientInvocationId))
.map(StreamInfo::getLocal)
.ifPresent(LocalStream::cleanUp);
.ifPresent(streamInfo -> {
streamInfo.getDivision()
.getDataStreamMap()
.remove(clientInvocationId);
streamInfo.getLocal().cleanUp();
streamInfo.applyToRemotes(out -> out.out.closeAsync());
});
}
}

Expand Down Expand Up @@ -423,6 +428,7 @@ private void removeDataStream(ClientInvocationId invocationId, StreamInfo info)
if (info != null) {
info.getDivision().getDataStreamMap().remove(invocationId);
info.getLocal().cleanUp();
info.applyToRemotes(out -> out.out.closeAsync());
}
}

Expand Down

0 comments on commit d2b563e

Please sign in to comment.