@spike-rabbit
Thanks to yourkit I could precisely find the problem.
There is no performance issue because of the code. Actually it does behave correctly. Since the monitoring interval is set to 1 second, there are often some objects created. But the garbage collector does only execute every minute, two minutes and even six minutes (once about 30MB are created for one type of monitoring callback, maximal there can be 3). It is configured by Java to garbage collect if it has to.
Nevertheless there is a solution:
-> After every monitoring full check the garbage collector is manually called (memory usage of monitoring low)
-> Theorethical DISADVANTAGE: This usually slows the system every second down (in terms of cpu, not memory). I can't garbage collect only some objects - everything or nothing. There is a possibility to garbage collect after for example 5 cycles, but that is only heuristically. I've set it to collect after each cycle and calculate it into the the wait interval of the cycles. If we have a high cpu usage issue because of that we should increase the cycles to wait before garbage collecting.
PLEASE KEEP THIS IN MIND!
But currently Thread time goes from 250ms to 70ms so there is actually a performance improvement. So no need to adjust the logic above.
@spike-rabbit Thanks to yourkit I could precisely find the problem. There is no performance issue because of the code. Actually it does behave correctly. Since the monitoring interval is set to 1 second, there are often some objects created. But the garbage collector does only execute every minute, two minutes and even six minutes (once about 30MB are created for one type of monitoring callback, maximal there can be 3). It is configured by Java to garbage collect if it has to.![unbenannt](https://cloud.githubusercontent.com/assets/6270463/10138444/c1b147c2-65fe-11e5-827f-b07f67992135.PNG)
Nevertheless there is a solution: -> After every monitoring full check the garbage collector is manually called (memory usage of monitoring low) -> Theorethical DISADVANTAGE: This usually slows the system every second down (in terms of cpu, not memory). I can't garbage collect only some objects - everything or nothing. There is a possibility to garbage collect after for example 5 cycles, but that is only heuristically. I've set it to collect after each cycle and calculate it into the the wait interval of the cycles. If we have a high cpu usage issue because of that we should increase the cycles to wait before garbage collecting. PLEASE KEEP THIS IN MIND! But currently Thread time goes from 250ms to 70ms so there is actually a performance improvement. So no need to adjust the logic above.
@spike-rabbit If seen, please close this issue.