How to read GC Logs



Let see how to read GC logs. In this post we will see how to get GC logs with following debug flags like -verbose:gc and  XX:PrintGCTimeStamps compare the GC output.



To enable verbose GC output use the follwing java options when starting the JVM:
-verbose:gc
 
The output looks like this (and can vary slightly from different version of the JVM):
 [GC 46336K->3775K(129664K), 0.2158256 secs]
 
This line represents a partial GC, as can been seen by the first part of the line:
[GC
 
if this GC had been a full GC, the first part of the output would be:
[Full GC
 
The other fields are as follows:
46336K->3775K 
-- size before and after the GC
(129664K) 
-- total available space, not counting the space in perm
0.2158256 secs
-- time the GC took


Another example, this time with a Full GC:
[Full GC 20260K->13975K(129792K), 0.5393601 secs]
 
20260K->13975K
-- size before and after the GC
(129664K)
-- total available space, not counting the space in perm
0.5393601 secs
-- time the GC took


Time stamps can be added to the output by adding the following option to the Java options:
-verbose:gc -XX:+PrintGCTimeStamps
 
which prints a time stamp at the beginning of the line, relative to the time the JVM was started, in seconds
127.720: [Full GC 20260K->13975K(129792K), 0.5393601 secs]
176.532: [GC 56794K->17083K(129792K), 0.1041413 secs]
 

Post a Comment

0 Comments