The sun JVM outputs detailed GC logs to StdOut when the following args are used.
-verbose:gc
-XX:+PrintGCTimeStamps
-XX:+PrintGCDetails
However, I don't want the output in StdOut and I dont really need the detail for every single GC. Is it possible to access the data used for these logs programatically? I would like to be able to log to my own log file the amount of memory allocated/collected and ideally the average object size over time.
You need to add
-Xloggc:log_file_name
This file gets reinitialized every time the JVM starts, so dont forget to move it to safe location if you want to keep it for analysis.
A complete list of the many command line options Java understands can be found here for Java 6.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With