Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a buffer memory leak in NettyReadHandlerStateMachine #18323

Merged
merged 3 commits into from
Oct 27, 2023

Conversation

jiacheliu3
Copy link
Contributor

@jiacheliu3 jiacheliu3 commented Oct 25, 2023

What changes are proposed in this pull request?

resolves #18324

Disclaimer: I might have monkey-typed this fix but I still do not know anything about buffer ref counting. This fix does NOT make me the owner of this state machine.

@@ -672,6 +672,8 @@ private void readData(RequestContext requestContext, Transition<State, TriggerEv
requestContext.getRequest());
}
fireNext(mTriggerEventsWithParam.mOutputLengthFulfilled, requestContext);
// Release the packet as there is nothing more to read
packet.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.

i'm not really sure if it's best to release here or actually before the fireNext(). The fireNext() might throw an exception somehow? And I figure fireNext() is not using this packet anyways.

Or would there be a better place than here, to release the packetReader.getDataBuffer() instead of releasing on the temp variable like what I'm doing? Who cleans up the resources in the context?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is OK for this case, but I am concerning if there are other Bytebuf memory leak scenarios.

@JiamingMai JiamingMai added the type-bug This issue is about a bug label Oct 25, 2023
Copy link
Contributor

@JiamingMai JiamingMai left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@dbw9580 dbw9580 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks a lot for finding out the leak!

@jiacheliu3
Copy link
Contributor Author

alluxio-bot, merge this please

@alluxio-bot alluxio-bot merged commit 14efca9 into Alluxio:main Oct 27, 2023
12 checks passed
ssz1997 pushed a commit to ssz1997/alluxio that referenced this pull request Dec 15, 2023
### What changes are proposed in this pull request?

resolves Alluxio#18324

Disclaimer: I might have monkey-typed this fix but I still do not know anything about buffer ref counting. This fix does NOT make me the owner of this state machine.

			pr-link: Alluxio#18323
			change-id: cid-eb5bde353c08d3d9bdd39da5b9caf13681bae495
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug This issue is about a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Netty direct memory leak from buffer
4 participants