-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Bug Report
Firstly, here is the link to the private repository with a sample app that helps to reproduce the leak, or, to be more precise, clearly shows that lettuce behavior from the direct memory usage perspective changed between 5.1.8 and 5.2.x: https://github.com/Shaphan/lettuce-direct-memory-leak-reproducer
Access to the repository is already granted to @mp911de
I can also share the repository with somebody else, if necessary, but would like to avoid making the repository public for the time being.
After upgrading to io.lettuce:lettuce-core:5.2.2.RELEASE
we started seeing increased memory consumption. We tracked this down to direct memory and preliminarily identified the commit 4f026e6 as the one introducing the issue in 5.2.x
branch (was addressing issue #906, PR #916).
Current Behavior
Faster direct memory growth in 5.2.2.RELEASE
as compared to 5.1.8.RELEASE
.
Higher probability to run into OutOfDirectMemoryError
s / OutOfMemoryError
s under the same conditions.
Expected behavior/code
Direct memory usage at the same level as in versions prior to 5.2.x.
Environment
- Lettuce version(s): 5.2.2.RELEASE, 5.3.0.RELEASE
- Redis version: we were running into the issue on 5.0.6 and 5.0.7, but the version of Redis should not really matter here
- Java 8+
Possible Solution
In our code we worked that around with help of reflection setting bufferUsageRatio
in io.lettuce.core.ClientOptions.Builder
.
This effectively makes CommandHandler
behave in pre-5.2 way.
An example:
ClientOptions.Builder optionsBuilder = ClientOptions.builder()
Field field = ClientOptions.Builder.class.getDeclaredField("bufferUsageRatio");
field.setAccessible(true);
field.setInt(optionsBuilder, 0);
...
Additional context
Please find screenshots showing direct memory usage from the aforementioned Sample app runs on different versions of lettuce (all the other parameters were the same):