- -Xnoclassgc: This is used to disable class garbage collection.
This may lead to irrecoverable out of memory errors, and unless the reason for setting this flag is known thoroughly along with the consequences, setting this flag is not recommended.
- -XX:MaxGCPauseMillis: Sets the maximum desired number of milliseconds the garbage collector can pause the VM. This is only respected for the "throughput collector" or "parallel collector." In CMS, it has no effect. There is no default for this setting, so it has to be set for the garbage collector to meet a particular goal. However, it tries to meet this goal before meeting the GCTimeRatio goal.
- -XX:GCTimeRatio: Sets a goal for the throughput collector to avoid spending more than a certain amount of time doing garbage collection.
By default the value is 99, meaning the application should get at least 99 times as much time as the collector. That is, the collector should run for not more than 1% of the total time.
- -XX:-DisableExplicitGC: Disable calls to System.gc(), JVM still performs garbage collection when necessary.
It is dangerous for a misbehaving in-memory component to continuously issue System.GC calls when the Heap memory allocated is large. This option will disable actions against explicit calls. The memory of the server is best managed by the VM.
37.6.1 GC Algorithms
- -XX:+UseConcMarkSweepGC: This concurrent low pause collector is used to collect the tenured generation and does most of the collection concurrently with the execution of the application. The application is paused for short periods during the collection. A parallel version of the young generation copying collector is used with the concurrent collector.
Works well for long running servers with a large heap memory that can afford to share CPU cycles with the garbage collector. Would result in the lowest pause times.
- -XX:+CMSIncrementalMode: This flag enables the incremental mode.
For systems with 1 or 2 processors, this might make CMS run more smoothly and avoid concurrent mode failures because it actually does tiny stop-the-world phases to do some of its concurrent work instead of relying on the OS to give it an appropriate time-slice for a thread.
- -XX:+UseParallelGC: Selects the parallel garbage collector for the new generation of the Java heap . This collector is also referred to as the throughput collector. It uses a parallel version of the young generation collector. The old (tenured) generation is still cleaned with the default collector.
By default on a host with N CPUs, the parallel garbage collector uses N garbage collector threads in the collection. The number of garbage collector threads can be controlled with a command line option -XX:ParallelGCThreads=<desired number>
37.6.2 GC logging
- -Xloggc:filename: Directs a smaller set of data to a file specified by filename. For every garbage collection, the following six fields are printed to the log file:
- Cumulative time since data collection began (in seconds)
- Garbage collection type
- Heap in use before the GC event
- Heap in use after the GC event
- Current maximum heap size
- Duration of the GC event
- -XX:+PrintGCDetails: More data is available if you start the JVM with the -XX:+PrintGCDetails or -XX:+PrintHeapAtGC options.
Instructs the VM to be more verbose when printing out garbage collection data. Specifically it does not only tell you that there was a collection, but also what impact it had on the different generations. This flag is very useful when tuning generation sizes. In conjunction with -Xloggc this is the best setting for the free GCViewer.
- -XX:+PrintGCDetails -Xloggc: filename prints the details into file with name specified by filename
- -XX:+PrintGCTimeStamps: Prints the times at which the GC happens relative to the start of the application. Available only from J2SE1.4.0
- -XX:+PrintTenuringDistribution: This it used to generate the aging information of objects in young generation. It shows the threshold and the ages of objects in the new generation. It is also useful for observing the lifetime distribution of an application.