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

Is there a need to release unpooled heap buffers? #9991

Closed
raner opened this issue Feb 3, 2020 · 1 comment
Closed

Is there a need to release unpooled heap buffers? #9991

raner opened this issue Feb 3, 2020 · 1 comment

Comments

@raner
Copy link

raner commented Feb 3, 2020

I am aware that it is best practice to release() locally created buffers in a finally block.
However, is this strictly necessary for unpooled heap buffers (i.e., buffers obtained via Unpooled.buffer())?
My understanding is that unpooled heap buffers are entirely allocated on the Java heap, and their lifecycle is managed by the garbage collector, but I could be wrong on this.
BTW, this question is similar to #8139 but regarding a different type of buffer.

@normanmaurer
Copy link
Member

@ran-su generally speaking no... that said by default we will still report it as leak to make it easier for people to switch between allocators. Even if the GC manage the unpooled buffers we will ensure to give the direct memory back in a fast fashion when calling release. So all in all it is preferred to do so.

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

No branches or pull requests

2 participants