Cosmos 3.X | Address memory leak in Direct TCP transport client #9211
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.
Repro
direct
testsspring-data-cosmosdb/src/test/resources/application.properties
:grep grep --context=15 --line-number "LEAK" /path/to/azure-cosmos.direct.output /path/to/spring-data-cosmosdb.output
Observe
All tests pass and a number of leaks were detected. Examples:
RntbdRequestTimer
RntbdResponse.release
Fix
This is a port from v2. See Azure/azure-cosmosdb-java#326 for a description of the change.
Test results
You will see in the before/after test results that this fix eliminates a memory leak in the Direct TCP stack. Performance numbers are provided for comparison with v4 master. There's some evidence in the comparison between v4 fix and v4 master that performance has improved some.
You will also see that for two test profiles (direct and emulator) there are some lingering leak detections. This is different than on the 2.6.X and 4.X branches where these leaks are not detected. I will get to the bottom of these issues in a second PR:
Path 1 (direct)
Path 2 (emulator)
azure-cosmos before/after test results
Client
Cosmos
Test Script
spring-data-cosmosdb before/after test results
Client
Cosmos
Test Script
** Instructions for viewing before/after test results **
Download tar ball,
spring-data-cosmosdb.results.tar.gz
, and thenFrom the directory containing the downloaded tar ball:
Notice this grep output (from the before test runs)
Also notice this grep output (from the after test runs)
Performance numbers
Client
Cosmos