question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

io.netty.util.internal.InternalThreadLocalMap,memory leak

See original GitHub issue

Expected behavior

No memory leaks occur

Actual behavior

undeploy my web application.

Steps to reproduce

I use elasticsearch jar and it contains netty. when I close the ESClient in the contextDestroyed, the Glassfish logs show severe error, as follows.

Minimal yet complete reproducer code (or URL to code)

The web application [/service_generic_log] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@5eeeaf73]) and a value of type [io.netty.util.internal.InternalThreadLocalMap] (value [io.netty.util.internal.InternalThreadLocalMap@6304ac92]) 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.

Netty version

netty-3.10.6 Final.jar
netty-buffer,codec,codec-http,common,handler,transport,handler-4.1.9.Final.jar

JVM version (e.g. java -version)

openjdk version “1.8.0_111” OpenJDK Runtime Environment (build 1.8.0_111-8u111-b14-2ubuntu0.16.04.2-b14) OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)

OS version (e.g. uname -a)

Linux lyk 4.6.2-040602-generic #201606100516 SMP Fri Jun 10 09:18:34 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:6
  • Comments:33 (13 by maintainers)

github_iconTop GitHub Comments

5reactions
vidhyasriramulucommented, Aug 18, 2018

Iam also having the same issue

SEVERE [localhost-startStop-2] org.apache.catalina.loader.WebappClassLoaderBase.checkThreadLocalMapForLeaks The web application [apprity] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1994ff12]) and a value of type [io.netty.util.internal.InternalThreadLocalMap] (value [io.netty.util.internal.InternalThreadLocalMap@7d6a4e1e]) 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.

is there any solution for this ?

3reactions
scruz-denodocommented, Dec 1, 2020

Hi, I uploaded a repository with steps for reproducing the issue: https://github.com/scruz-denodo/netty-thread-local-issue

It contains two ways for checking the problem.

  • Only with Netty.
  • Netty + Tomcat for seeing the log error.

Some comments:

  • It seems that InternalThreadLocalMap is attached as ThreadLocal to the thread that executes the connect on the client side:
   bootstrap = new Bootstrap();
   b.connect(host, port);   //Here
  • The threadlocal remains at the thread when netty connections are closed.
  • Thread used for opening the connection remains with that threadLocal value, so:
    • it could be a problem reusing the same thread for opening a different connection?. At the Only wtih Netty sample the thread are from a ExecutorService, so in a real application those threads could be used for any other task. Also, when problem happens at Netty + Tomcat, those threads are the tomcat executor threads “http-nio-exec”, so they are shared between different applications.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

io.netty.util.internal.InternalThreadLocalMap,memory leak
Expected behavior. No memory leaks occur. Actual behavior. undeploy my web application. Steps to reproduce. I use elasticsearch jar and it ...
Read more >
ResourceLeakDetector.Level (Netty API Reference (4.0.56 ...
Enables advanced sampling resource leak detection which reports where the leaked object was accessed recently at the cost of high overhead. DISABLED. Disables ......
Read more >
How to find a root cause of the following netty error: io.netty.util ...
Above exception could have 2 reasons: You have memory leak in your app (most probably);; You really create big load or allocate many...
Read more >
Memory leaks when trying to get Netty server publish ...
I am hitting memory leak issues when I load testing my server. ... at io.netty.util.internal. ... [nioEventLoopGroup-3-2] ERROR io.netty.util.
Read more >
A Netty ByteBuf Memory Leak Story and the Lessons Learned
Just a while ago, I was chasing a memory leak we had at Logz.io while I was refactoring our log receiver. We were...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found