Too many thread pools created
See original GitHub issueHi, recently, i have met a problem, when i use the JdbcImporter for a while , too many threads are created(about 2000 in 10 hours), and no thread is destroyed, after analyzed by jstack, i find that the threads are all named like ‘pool-{threadpool-num}-thread-1’, and when i check the code, i think problems are here in JdbcImportor:
private void execute() throws ExecutionException, InterruptedException {
logger.debug("executing (queue={})", getQueue().size());
executor = new MetricSimplePipelineExecutor<SettingsPipelineRequest, Pipeline<SettingsPipelineRequest>>()
.setQueue(getQueue())
.setConcurrency(settings.getAsInt("concurrency", 1))
.setPipelineProvider(pipelineProvider())
.prepare()
.execute()
.waitFor();
logger.debug("execution completed");
}
each time the execute
method is invoked, a new ThreadPool is created, and the pool will never be destroyed, as time goes by, too many thread pools are created, and because the concurrency is 1, there are also too many threads!
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Creating too many threads in Java - Stack Overflow
I suspect that the JVM is not putting back the completed threads back in to the pool as soon they are finished, hence...
Read more >Thread Pools in Java — Why use multiple Thread ... - Medium
The purpose of having separate dedicated thread pools is so that an activity doesn't get starved for threads because other activities took all ......
Read more >Why Too Many Threads Hurts Performance, and What to do ...
The impact of having too many threads comes in two ways. First, partitioning a fixed amount of work among too many threads gives...
Read more >Finally Getting the Most out of the Java Thread Pool - Stackify
Thread pools provide a significant advantage by, simply put, separating the execution of tasks from the creation and management of threads.
Read more >Java Thread Pools and ThreadPoolExecutor - HowToDoInJava
Creates a thread pool that reuses a fixed number of threads to execute any number of tasks. If additional tasks are submitted when...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
i have changed two places to solve the problem.
the first one is in JdbcImporter:
i have added the
shutdown
method to shutdown the ThreadPool created by last call.the second one is in
StandardSink
:i haved added this line:
this lines allow me to control whether or not to switch on the ‘GcMonitor’, the Monitor will be scheduled each time the
execute
method invoked in JdbcImporter, so each time a new ThreadPool will be created.so my problem : too many threadpools are created but no one is destroy, and my solution:
GcMonitor
, so that no thread pool will be createdthe second solution is not a good practice because i think it is a bug which need to be fixed
Let me close this…