Skip to content

Conversation

@SophieGuo410
Copy link
Contributor

Summary

Fix memory leak for batch delete

Testing Done

unit test

Comment on lines 199 to 202
} finally {
if (byteBuffer != null) {
byteBuffer.release();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we only seeing this issue now? Were we relying on the garbage collector? Is there increased load in batch delete requests that prevents the garbage collector from keeping up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is direct memory leak. so no gc, we have to release them.
we only see bunch of these when we enable the paranoid mode and the direct memory usage goes up to 20G.
we will keep investigate other leaks

throw new RestServiceException("failed to deserialize", e, RestServiceErrorCode.BadRequest);
} finally {
if (byteBuffer != null) {
byteBuffer.release();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does consumeContentAsBuf increase ref count? is that why release is being done here? is channel.close() getting called correctly?

Copy link
Contributor

@satishkotha satishkotha Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like consumeContentAsByteBuf transfers ownership. can we refactor that method to be safe? something like:

public byte[] consumeContentAsBytes() {
ByteBuf buf = null;
try {
buf = // consumeContentAsByteBuf() code
byte[] data = new byte[buf.readableBytes()];
buf.readBytes(data);
return data;
} finally {
if (buf != null) { buf.release() };
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@SophieGuo410 SophieGuo410 merged commit b4d01bd into master Oct 29, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants