Usage:
This flag sets a maximum size of each Garbage Collector (GC) log. Its syntax is the following:-XX:GCLogFileSize=value, value is the maximum size of the log.
Since:
Starting from JDK 6.
Removed:
Since from JDK 9.
Examples:
To set a maximum size of the GC log to 100 Megabyte:
java -XX:GCLogFileSize=100M
Description:
Garbage Collector 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.
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 “GCLogFileSize” which sets a maximum size of the GC log. When the current written GC log exceeds that maximum, the JVM will stop writing to it and create a new file to append to it.
You can also specify a data unit such as “k” or “K” for kilobytes, “m” or “M” for Megabytes and “g” or “G” for Gigabytes.
- For using 512 Kilobytes: -XX:GCLogFileSize=512k
- For using 128 Megabytes: -XX:GCLogFileSize=128m
- For using 12 Gigabytes: -XX:GCLogFileSize=12g
Default Value:
The default value is 512K.
Note:
You should avoid setting a high size which might cause a memory issue or it might overwrite the recent lines.
Arguments related:
Xloggc, PrintGCDetails, PrintGCDateStamps, PrintGCTimeStamps, PrintGCCause, UseGCLogFileRotation, NumberOfGCLogFiles
Related Posts:
Edit your Comment