I would like to track how much time is spent in GC and how much memory has been collected, but not by analysing GC logs (ie. analyzing what I got from -XX:+PrintGCWhatever).
I found that I can use Sun's ManagementFactory to get a GarbageCollectorMXBean that can give me some GCInfo object containing memory information but I have no guarantee I can collect all GC through this mean.
Does anybody know of a way to do this in code?