So, can only develop A front system, A system of the request is sent to the front system, through the front system, to initiate the request, B system and the response results back to A system, the aim is to make the two systems can exchange network, and is limited to the URL configuration, not the whole network proxy, reduce risk,
Now the front system, I use is okHttp3 the network framework for a HTTP request, when doing performance testing, send, okHttp3 every request, will create a thread, thread in idle after 60 seconds, automatically recycling, problem here, under the high concurrency, add the number of threads is greater than the recovery of the number of threads, so the memory leak caused by not enough resources,
Saw the okhttp framework source code, found that it has a ConnectionPool class, there is a static initialization code thread pool,
The static {
Executor=new ThreadPoolExecutor (0, 2147483647, 60 l, TimeUnit. SECONDS, new SynchronousQueue will (), Util. ThreadFactory (" OkHttp ConnectionPool ", true));
}
From here you can see, it is 2147483647 maximum number of threads, free time is 60 seconds recycling, originally, the framework of the android system using object, because it is impossible for users to high concurrent to the point of a button, or there is no problem, won't produce how many threads, and a minute later will be recycled, but, I use in Java web system, forward requests high concurrency thousands of TPS, at this time is the memory leak problem, check the number of threads, as high as more than 2000,
I'm not sure whether I use has a problem, to request the great god of CSDN, what channels or whether to use parameter is set to solve the problem, thank you very much
CodePudding user response:
I also would like to know how to solve