2

I'm writing a program which is sensitive to garbage collection stop-the-world events. I would like the program to identify moments when the garbage collection causes stops, or the amount of time spent stopping, and notify the user when this passes a threshold.

I'm aware of external tools that can be used to monitor garbage collection (jstat, options when executing java runtime), but I'd like to do this from within my program.

A bit more background: my program is a performance test executor for SQL queries. The user specifies queries and their rate of execution, the program executes and measures response times. If the user specifies too high a rate, the amount of garbage created by these executions becomes quite high and the response time measured includes the garbage collection induced pauses, thus giving inaccurate measures. Hence the need to warn the user that the program is overloaded when this happens.

Thanks -- Florian.

florian-x
  • 61
  • 6
  • 1
    You can use the JMX beans to monitor how much time is spent in GC pauses. However, I would suggest using a memory profiler to reduce the amount of garbage you produce, so it is always low enough. You can write systems which can run all day without a GC if you keep your garbage low enough. – Peter Lawrey May 08 '14 at 10:02
  • Thanks Peter. Will just look at cited post and JMX beans. Making it so that "it is always low enough" doesn't work for me, because it's the user who can specify whatever workload he wants... and before being CPU-bound, the workload will create too much garbage. – florian-x May 08 '14 at 10:05

0 Answers0