Usage:
Set a number of Garbage Collector log (GClog) files to be rotated. Its syntax is: -XX:NumberOfGClogFiles=value, where value is the number of rotated GClog files.
Since:
Starting from JDK 6.
Examples:
To set a number of rotated files to 3:
java -XX:NumberOfGClogFiles=3 MainClass
Description:
Garbage Collector (GC) is a way of the JVM to clean the memory and makes the java memory more efficient. It tracks (Mark step) and removes (sweep step) every unused object available in the JVM heap space. An object is considered unused when it’s referenced by null, assigned to another reference or by anonymous object.
Log rotation is a process where the log files are renamed, archived, compressed or deleted when they are large and new logs are written directly to a new log file.
To analyze JVM performance, you must look at the Garbage Collector (GC) log because they are essential to understand your application performance and see what causes memory issues. The logs can be generated with the flag “Xloggc”. However, the GC log file will grow in size while the JVM is still running and it might cause issues. Luckily, JVM introduced some arguments to manage the GC logs such as rotating and sizing them. One of these flags is “NumberOfGCLogFiles” which set a number of rolling Garbage Collector log (GClog) files. The naming of those GClog files will respect the following standard: <gclog-name>.0, <gclog-name>.1 … <gclog-name>.n where n is the number giving to the argument (the filename “gclog-name” used is just an example).
Default Value:
By default, the number of rotated files is 0, which means there is no GClog rotation.
Error:
An exception is thrown if the value is below strictly to 1.
Arguments related:
Xloggc, UseGCLogRotation, PrintGCDetails, PrintGCDateStamps, PrintGCTimeStamps, PrintGCCause, UseGCLogFileRotation, GCLogFileSize
Related Posts:
Edit your Comment