redisson: Getting memory leak warnings when gracefully shutting down tomcat

I am getting warnings about potential memory leaks when gracefully shutting down tomcat:

28-Aug-2016 18:59:01.385 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [tenant-management-webapp] created a ThreadLocal with key of type [java.lang.ThreadLocal](value [java.lang.ThreadLocal@42b3dc05]) and a value of type [io.netty.util.internal.InternalThreadLocalMap](value [io.netty.util.internal.InternalThreadLocalMap@19a704b7]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. 28-Aug-2016 18:59:05.211 SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [user-settings-webapp] created a ThreadLocal with key of type [java.lang.ThreadLocal](value [java.lang.ThreadLocal@8117ba6]) and a value of type [io.netty.util.internal.InternalThreadLocalMap](value [io.netty.util.internal.InternalThreadLocalMap@6684e4af]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

In each webapp I configure a RedissonClient bean with a “useSingleServer” config:

@Configuration
public class RedissonConfig {

    @Lazy
    @Bean(destroyMethod = "shutdown")
    public RedissonClient postConstruct() {
        String host = "192.168.99.100";
        Integer port = 6379;
        Integer connectionMinimumIdleSize = 5;

        Config config = new Config();

        SingleServerConfig singleServerConfig = config.useSingleServer();
        singleServerConfig.setAddress(host + ":" + port);
        singleServerConfig.setConnectionMinimumIdleSize(connectionMinimumIdleSize);

        return Redisson.create(config);
    }
}

After that I use this bean by autowiring it in other spring beans:

import org.redisson.RedissonClient;
import org.redisson.core.RLock;

@Component
@Lazy
public class LockingService {

    @Autowired
    private RedissonClient redissonClient;

    public void lock(String resourceId) {
        RLock lock = redissonClient.getLock(resourceId);
        lock.lock();
    }

    public void unlock(String resourceId) {
        RLock lock = redissonClient.getLock(resourceId);
        lock.forceUnlock();
    }
}

versions: redisson 2.2.23 spring 4.2.4.RELEASE tomcat 8.5.4 java 1.8

Any idea why this happens?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 27 (11 by maintainers)

Commits related to this issue

Most upvoted comments

@mrniko Thx, Can you show more details about your solution?

@jackygurui thx for your share at the yunqi conference.

@SimonCigoj what about debugging what file handlers are open? As you are on Windows it could be that undeploy is taking a long time because deletion cannot succeed as file(s) are in use.