Search code examples
spring-bootredisnettyspring-data-redis

o.lettuce.core.RedisException::io.netty.util.internal.OutOfDirectMemoryError while retrieving a big object(2MB)from Redis


I have a Springboot application that connects to Redis cache ( Azure redis) and retrieve an object . The object size is 2MB . I am getting the following error some times .

io.lettuce.core.RedisException: io.netty.util.internal.OutOfDirectMemoryError: failed to allocate 524288000 byte(s) of direct memory (used: 553648128, max: 1073741824)"}.

It is not happening every time . Why it is allocating 524288000 byte(s) to retrieve a 2MB object ? When it is working , I get the response in 1 sec .

Details :

Spring boot version : 2.1.5

Spring data redis : 2.1.8

Lettuce core : 5.1.6

io.Netty : 4.1.36

Deployment environment Deatils :

Enviornment: Pivotal Cloud Foundry environment

Memory : 2GB with a direct memory of 1GB

Redis :

Azure Premium Redis with 6GB memory.

Code snippet :

To retrieve the object , I am using the following piece of code :

redisTemplate.opsForValue().get(keyname);

and then convert to the Object using an ObjectMapper.

and all default properties .


Solution

  • As the allocation seems to happen as part of lettuce I would suggest opening a bug report there. This does not sounds correct.