DirectByteBuf implementations should not force free memory #893
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation:
ServiceTalk doesn't expose reference counting and relies upon GC for memory
reclamation. Buffer objects are resizable an in the event a buffer is resized
(e.g. a write operation needs to expand the buffer) this will result in
allocating new memory and Netty will attempt to deallocate the old memory.
Applications may be multi-threaded and it is possible another thread will still
have a reference to this old memory location due to visibility constraints. We
should prevent Netty from force-freeing this old memory and instead rely upon GC
to avoid undefined behavior.
Modifications:
and do nothing.
Result:
Less risk for resize operation resulting in referencing freed memory.