简体   繁体   中英

JBoss + Netty + Connection reset by peer = Thread leak

I have an application that uses netty to handle communication with some external devices. The application runs on JBoss EAP 6.1. It seems that when a device tears down the connection the running thread count increases, but does not decrease after the TIME_WAIT connection is removed. It looks like this:

  1 LISTEN
Threads:    207
  1 LISTEN
  1 TIME_WAIT
Threads:    211
  1 LISTEN
  1 TIME_WAIT
Threads:    211
  1 LISTEN
  1 TIME_WAIT
Threads:    210
  1 LISTEN
  1 TIME_WAIT
Threads:    209
  1 LISTEN
  1 TIME_WAIT
Threads:    209
  1 LISTEN
  1 TIME_WAIT
Threads:    209
  1 LISTEN
Threads:    209
  1 LISTEN
Threads:    209

As you can see the thread count before connection is 207, when the connection is established and broken by the device the thread count is 211 - down to 209, but it never goes down to 207. Every next occurence of the above scenario causes the thread count to increase so eventually OutOfMemory is thrown. I've added some logging to run() method of each custom Thread class I implemented so I can match "Thread started" with "Thread ended" and it seems that all custom threads end up. What can be the reason of this problem?

I think you are not calling shutdownGracefully on the EventExecutorGroup . That should solve your problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM