Dear All;
I write this piece of code to force one of my tasks to work in parallel. The loop at least iterate 5500 times. After afew iteration the system overloaded and stop responding due to Garbage Collection tasks. Please tell me what is wrong and how I can improve the code.
Since, the code is to long I try to simplify the problem. I create a ExecutorService and a Fixed pool equal to
"numberOfCPUsAvailable" in a loop in order to lunch "numberOfCPUsAvailable" threads in each iteration. The loop
iterate at least 5500 times. In each runable I compare a member of and object array with the rest from beginning to that object. After few iterations the system not responding. I increase the heap size in order to prevent GC to start repeatedly and useMarkSweepGC but it is not effective.
for (int i = 5500; i >= 0 ; i--) { distanceExecutor = Executors.newFixedThreadPool(numOfAvailableCPUs); AntibodyDistanceChecker[] DCT = new AntibodyDistanceChecker[numOfAvailableCPUs]; int step = (int) Math.floor(totalUnique / numOfAvailableCPUs ); for(int t = 0; t < numOfAvailableCPUs; t++) { DCT[t] = new AntibodyDistanceChecker("DCT"+t+i, minAllowedDistance); } for(int e = 0; e < numOfAvailableCPUs; e++) distanceExecutor.execute(DCT[e]); distanceExecutor.shutdown(); while (!distanceExecutor.isTerminated()) {} distanceExecutor = null; DCT = null; }