awslabs / aws-crt-java

Java bindings for the AWS Common Runtime
Apache License 2.0
53 stars 40 forks source link

S3 client creation leaks memory #823

Closed steven-aerts closed 2 weeks ago

steven-aerts commented 3 weeks ago

Describe the bug

Every time a crt S3 client is created it will leak memory, as it is not cleaning up its TLS Contexts correctly.

This issue was detected in our production environment and is also tracked under AWS Support ticket172363023300722.

Expected Behavior

Memory leaks

Current Behavior

No Memory Leaks

Reproduction Steps

Execution the following code will exhaust the memory of the machine it runs on:

for(;;) {
    try(
            var tlsc = new TlsContext();
            var c = new S3Client(new S3ClientOptions()
                    .withRegion("eu-west-1")
                    .withClientBootstrap(ClientBootstrap.getOrCreateStaticDefault())
                    .withTlsContext(tlsc)
    )) {

    }
}

This snippet was derived from production usage of the higher level S3AsyncClient.createCrt() function.

Possible Solution

No response

Additional Information/Context

No response

aws-crt-java version used

0.30.3

Java version used

21

Operating System and version

Linux

jmklix commented 3 weeks ago

Thanks for making the PR, we're testing it before merging it.

jmklix commented 2 weeks ago

The PR with the fix is here, along with test for memory leaks. Please wait for the Java sdk to update with the latest version of aws-crt-java.