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 Bug : RemoveCachedBodyFilter does not release direct memory correctly resulting in a memory leak #2969 #2971

Closed

Conversation

caixunshi
Copy link
Contributor

Fixes #2969

RemoveCachedBodyFilter uses the remove method to remove CACHED_REQUEST_BODY_ATTR from the exchange object, but it cannot guarantee that the dataBuffer will be released correctly.

When calling ServerWebExchangeUtils.cacheRequestBody multiple times in the project to generate a nested multi-layer ServerHttpRequestDecorator, it will cause a memory leak and eventually throw an OutOfDirectMemoryError

So in RemoveCachedBodyFilter, it should be ensured that the cached dataBuffer is released correctly.

This PR contains a fix for this problem. The idea is to ensure that databuf is released correctly by judging the return value of release.

Please review this PR, if looks ok please approve it.

@caixunshi
Copy link
Contributor Author

@spencergibb

@chocotan
Copy link

After several days of troubleshooting, we finally discovered that this pull request is the correct solution.

#2842 with this commit can not fix memory leak problem completely.

@caixunshi
Copy link
Contributor Author

@spencergibb why hasn't this PR request been addressed yet? Is there any issue with it?

@spencergibb
Copy link
Member

Closed via aa88517 and polished in ea3662d

@dtsukinovsky

This comment was marked as duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

RemoveCachedBodyFilter does not release direct memory correctly resulting in a memory leak
5 participants