Fix SharedBytes mmap leak by closing parent arena on close#142460
Merged
ChrisHegarty merged 4 commits intoelastic:mainfrom Feb 13, 2026
Merged
Fix SharedBytes mmap leak by closing parent arena on close#142460ChrisHegarty merged 4 commits intoelastic:mainfrom
ChrisHegarty merged 4 commits intoelastic:mainfrom
Conversation
Collaborator
|
Pinging @elastic/es-distributed (Team:Distributed) |
Collaborator
|
Hi @ChrisHegarty, I've created a changelog YAML for you. |
fcofdez
approved these changes
Feb 13, 2026
x-pack/plugin/blob-cache/src/test/java/org/elasticsearch/blobcache/shared/SharedBytesTests.java
Outdated
Show resolved
Hide resolved
sidosera
pushed a commit
to sidosera/elasticsearch
that referenced
this pull request
Feb 13, 2026
…42460) SharedBytes memory-maps its cache file using Arena.ofShared(), which requires explicit closing to release the mapping. The parent CloseableMappedByteBuffer objects (which own the arenas) were stored in a local variable in the constructor and never closed - only slices (with arena = null) were retained in the IO objects. As a result, mapped memory was never released until JVM exit, leaking the cache file's disk blocks even after the file was deleted. This is observable in tests that repeatedly create and tear down searchable snapshot infrastructure (e.g. VectorScorerOSQBenchmarkTests), where each iteration leaked a 16+ MB cache file. The fix retains the parent mmap buffers as a field and closes them in closeInternal() via IOUtils.close before closing the file channel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
SharedBytes memory-maps its cache file using
Arena.ofShared(), which requires explicit closing to release the mapping. The parentCloseableMappedByteBufferobjects (which own the arenas) were stored in a local variable in the constructor and never closed - only slices (witharena = null) were retained in theIOobjects. As a result, mapped memory was never released until JVM exit, leaking the cache file's disk blocks even after the file was deleted.This is observable in tests that repeatedly create and tear down searchable snapshot infrastructure (e.g.
VectorScorerOSQBenchmarkTests), where each iteration leaked a 16+ MB cache file. The fix retains the parent mmap buffers as a field and closes them incloseInternal()viaIOUtils.closebefore closing the file channel.This issue was caused by the changes in #140371