Profile Image
vishnupriya

What is JVM startup parameter: -XX:GCLogFileSize?

What is JVM startup parameter: -XX:GCLogFileSize? Have you used this JVM arguement before? What are the pros & cons of using this Java argument? Can you share your perspective/experience in using this JVM argument?

  • jvmargument

  • xx-gclogfilesize

  • x-gclogfilesize

  • JVM startup parameter

Please Sign In or to post your comment or answer

Profile Image

Pavel Khodakovsky

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:

Got something else on mind? Post Your Question

Not the answer you're looking for? Browse other questions tagged
  • jvmargument

  • xx-gclogfilesize

  • x-gclogfilesize

  • JVM startup parameter