Is it possible to get a notification when a long GC cycle occurs?
I'd like to write to our specific log when this happens.
Is it possible to get a notification when a long GC cycle occurs?
I'd like to write to our specific log when this happens.
Maybe not within the jvm, but you can start Java with the -verbose:gc option, this should create console output like [GC 511K->105K(1984K), 0.0029585 secs]. [1]
With some clever scripting you then can build an alert system on long GC cycles.
There is a possibility to log the activity of the garbage collector using JMX. Typically it is used to monitor the performance of large-scale java applications. Maybe this solution is a bit too full-blown for your needs but at least you would be able to monitor what the gargabe collector does.
JConsole is a nice littel tool that makes use of JMX to display some performace data.
I guess you could poll the GarbageCollectorMXBean and look out for the collection time jumping up.