Details
Description
( Issue initially reported here : https://forums.couchbase.com/t/the-v2-of-the-java-client-leaks-rxjava-threads-on-shutdown/3890 )
We use the couchbase client v2.1.3 in a webapp application : in development we use hot redeployment and we got memory issues probably caused by the fact that RxJava Threads are not stopped when we close the couchbase client :
After few redeployments several duplicated RxJava Threads are present and a memory dump shows that they hold the old classloaders.
The issue is easy to reproduce in a simple main class :
Just create de couchbase client Cluster, connect to a Bucket and do a little query then stop the Cluster (Cluster.shutdown).
Then if you dump the threads and you see there are still some RxJava Threads :
In my case before Cluster shutdown, I have these threads :
- 13 : cb-io-1-4
- 25 : threadDeathWatcher-4-1
- 12 : cb-io-1-3
- 11 : cb-io-1-2
- 10 : cb-io-1-1
- 23 : cb-computations-4
- 22 : cb-computations-3
- 21 : cb-computations-2
- 20 : cb-computations-1
- 19 : cb-core-3-2
- 18 : cb-core-3-1
- 16 : RxComputationThreadPool-3
- 15 : RxComputationThreadPool-2
- 14 : RxComputationThreadPool-1
(jvm threads ommitted)
And after the shutdown, there is still the following threads :
- 25 : threadDeathWatcher-4-1
- 23 : cb-computations-4
- 22 : cb-computations-3
- 21 : cb-computations-2
- 20 : cb-computations-1
- 16 : RxComputationThreadPool-3
- 15 : RxComputationThreadPool-2
- 14 : RxComputationThreadPool-1
(jvm threads ommitted)
(dumping threads with :
ThreadInfo[] threadInfos = threadMXBean.getThreadInfo(threadMXBean.getAllThreadIds());
for(ThreadInfo ti : threadInfos)
)
Attachments
Issue Links
- is triggered by
-
JVMCBC-251 Improve thread cleanup on shutdown
- Resolved
- relates to
-
JVMCBC-201 Environment should shutdown resources it created (and only them) properly
- Resolved