HDDS-15916. Native memory leak in ECKeyOutputStream: encoder.release() not called in close(), causing ISA-L native memory accumulation - #11180
Open
anuragp010 wants to merge 2 commits into
Open
Conversation
…) not called in close(), causing ISA-L native memory accumulation
jojochuang
reviewed
Sep 1, 2026
| blockOutputStreamEntryPool.cleanup(); | ||
| // Release the encoder's native resources (e.g. ISA-L coder context) | ||
| // that were allocated in the constructor. | ||
| encoder.release(); |
Contributor
There was a problem hiding this comment.
looks good. Maybe we want to do the same for the decoder object in ECBlockReconstructedStripeInputStream?
Contributor
There was a problem hiding this comment.
Yea it looks like the decoder in ECBlockReconstructedStripeInputStream has the same issue, so it would be good to fix both together here.
Contributor
Author
There was a problem hiding this comment.
Thanks for the review @jojochuang and @sodonnel . I'll update the PR to include a fix for ECBlockReconstructedStripeInputStream .
jojochuang
approved these changes
Sep 1, 2026
…econstructedStripeInputStream
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.
What changes were proposed in this pull request?
Any long lived client JVM which is writing EC Keys using
ECKeyOutputStreamleaks native memory. This occurs becauseECKeyOutputStream.close()never callsencoder.release(). WhenNativeRSRawEncoderis in use byECKeyOutputStream, each key creation results in acquiring native memory to store lookup tables used in calculation of Parity Data. This native memory is only freed by callingrelease(). This PR addsencoder.release()inECKeyOutputStream.close()to free the native memory.A similar native memory leak is present through the decoder in
ECBlockReconstructedStripeInputStream. This PR adds a conditionaldecoder.release()inECBlockReconstructedStripeInputStream.close()to free the native memory.What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-15916
How was this patch tested?
encoder.release()is called.Env Setup:
Build with
-Phadoop-native-lib:mvn clean package -Pdist -Phadoop-native-lib -DskipTests -DskipShade -DskipRecon -DskipDocsUpdate
docker-compose.yamlto includeisa-llibraries pre startingS3Gateway:Use
linux/amd64as the default platform:export DOCKER_DEFAULT_PLATFORM=linux/amd64Start the cluster:
docker compose up -d --scale datanode=5Running the test:
aws s3 $EP cp --recursive --storage-class STANDARD_IA /tmp/many s3://leaktest/r1/Results:
The RSS (Resident Set Size) for the s3 gateway process was captured after the runs with the fix and without the fix.
Commands used:
jcmd $PID GC.rungrep VmRSS /proc/$PID/statusPost-GC RSS floor of the S3 Gateway JVM
Without the fix, post each run, there is a clear upward trend in RSS of the
S3Gatewayprocess.