Vmflags
When it comes to garbage collector and memory flags VMS from different vendors differ somewhat. most flags aren't even properly specified ented by the usage printout of the VM themselves. this page tries to shine some light on what garbage collection related
Flags there are and what they are good for. It covers several
Sun and IBM JVMs
Sun JVMs
Disclaimer: Please note that the data presented in this document has been gathered from several publicly available sources. it is a conscious selection of available VM parameters and even though we tried to check most of the facts presented this document
May contain errors.
Choosing a VM
-Server
Instructs the VM to use the server hotspot VM. This also implies that default heap sizes and permanent generation sizes are different.
Under 1.5 this option is the default option, if the machine is
Server-class machine.
Supported by: 1.3, 1.4, 1.5
-Client
Instructs the VM to use the client hotspot VM. This also implies that default heap sizes and permanent generation sizes are different.
Supported by: 1.3, 1.4, 1.5
Printing information about GC
-Verbose: GC
Prints out information about garbage collections to standard out. to print the same information to a file, use
-Xloggc: <File>
Example:
[GC 325407 K-> 83000 K (776768 K), 0.2300771 secs]
[GC 325816 K-> 83372 K (776768 K), 0.2454258 secs]
[Full GC 267628 K-> 83769 K (776768 K), 1.8479984 secs]
See-xloggc
Supported by: 1.3, 1.4, 1.5
-Xloggc: <File>
Prints information about garbage collections to the specified file.
In conjunction
-XX: + printgcdetails this is the best setting for the free
Gcviewer.
Supported by: 1.4, 1.5
-XX: + printgcdetails
Instructs the VM to be more verbose when printing out garbage collecion 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
-Xloggc this is the best setting for the free
Gcviewer.
Example:
2.459: [GC 2.459: [defnew: 3967 K-> 0 K (4032 K), 0.0141600 secs] 8559 K-> 7454 K (16320 K), 0.0143588 secs]
Supported by: 1.4, 1.5
-XX: + printgcapplicationstoppedtime
Instructs the VM to print out the length of actual collection pauses.
This flag is useful when tuning concurrent collectors.
Example:
Total time for which application threads were stopped: 0.0468229 seconds
Supported by: 1.4, 1.5
-XX: + printgcapplicationconcurrenttime
Instructs the VM to print out the amount of time the applications runs between collection pauses.
This flag is useful when tuning concurrent collectors.
Example:
Application Time: 0.5291524 seconds
Supported by: 1.4, 1.5
-XX: + printgctimestamps
Ensures that timestamps relative to the start of the application are printed in the GC log.
Supported by: 1.4, 1.5
-XX: + printtenuringdistribution
Prints details about the tenuring distribution to standard out. it can be used to show this threshold and the ages of objects in the new generation. it is also useful for observing the Lifetime Distribution of an application.
Example:
5.350: [GC desired into vor size 32768 bytes, new threshold 1 (max 31)
-Age 1: 57984 bytes, 57984 total
-Age 2: 7552 bytes, 65536 total
756 K-> 455 K (1984 K), 0.0097436 secs]
Supported by: 1.3, 1.4, 1.5
Sizing heap and generations
-Xmx <value>
Overall maximum heap size. You may use K, M and G for kilobyte, megabyte and Gigabyte.
Example:
-Xmx256m sets the maximum heap size to 256 MB
Supported by: 1.3, 1.4, 1.5
-XMS <value>
Minimum heap size. You may use K, M and G for kilobyte, megabyte and Gigabyte.
Example:
-Xms256m sets the minimum heap size to 256 MB
Supported by: 1.3, 1.4, 1.5
-Xmn <value>
Sets the size of the young generation. You may use K, M and G for kilobyte, megabyte and Gigabyte.
Example:
-Xmn64m sets the young generation size to 64 MB
Supported by: 1.4, 1.5
-XX: minheapfreeratio = <minimuminpercent>
Sets the minimal percentage of free heap memory that has to be available after a collection. This parameter can be used to influence when the VM is going to request more memory.
Example:
-XX: minheapfreeratio = 70
See
-XX: maxheapfreeratio
Supported by: 1.3, 1.4, 1.5
-XX: maxheapfreeratio = <maximuminpercent>
Sets the maximal percentage of free heap memory that must at most be available after a collection. this parameter can be used to influence when the VM is going to lower its footprint. in other words it can shrink the heap and therefore memory consumption.
Example:
-XX: maxheapfreeratio = 20
See
-XX: minheapfreeratio
Supported by: 1.3, 1.4, 1.5
-XX: newratio = <ratio>
Sets the ratio between young and old generation.
Example:
-XX: newratio = 3 means that the ratio between the young and old
Generation is; in other words, the combined size
Eden and the specified vor spaces will be one fourth of
Heap.
See-XX: newsize and
-XX: maxnewsize
Supported by: 1.3, 1.4, 1.5
-XX: newsize = <value>
Sets minimum size of the young generation.
Example:
-XX: newsize = 64 m sets the minimum size of the young
Generation to 64 MB
See-XX: newratio and
-XX: maxnewsize
Supported by: 1.3, 1.4, 1.5
-XX: maxnewsize = <value>
Sets maximum size of the young generation.
Example:
-XX: newsize = 64 m sets the maximum size of the young
Generation to 64 MB
See-XX: newratio and
-XX: newsize
Supported by: 1.3, 1.4, 1.5
-XX: Required vorratio = <ratio>
Sets size of the specified vor spaces in relation to Eden.
Example:
-XX: Required vorratio = 6 sets the ratio between each between vor Space
And Eden to be; in other words, each into vor Space
Will be one eighth of the young generation (not one seventh,
Because there are two attached vor spaces ).
Supported by: 1.3, 1.4, 1.5
-XX: permsize = <value>
Sets the initial size of the permanent generation (where classes etc. are stored). This can be useful for application servers using ejbs and JSPs.
Example:
-XX: permsize = 64 m
See-XX: maxpermsize
Supported by: 1.3, 1.4, 1.5
-XX: maxpermsize = <value>
Sets the maximum size of the permanent generation (where classes etc. are stored). This can be useful for application servers using between ejbs and JSPs.
Example:
-XX: maxpermsize = 64 m
See-XX: permsize
Supported by: 1.3, 1.4, 1.5
Choosing and refreshing a collector
-XX: + useparallelgc
Use parallel garbage collection. This collector is also referred to as
ThroughputCollector. It uses a parallel version of the young generation collector. The old (Tenured) generation is still cleaned with the default collector.
Under 1.5 this option is the default option, if the machine is
Server-class machine.
This option can not be used in conjunction
-XX: + useconcmarksweepgc.
Supported by: 1.4.1, 1.5
-XX: + useparalleloldgc
Use the parallel old generation collector. certain phases of an old generation collection can be saved med in parallel, speeding up an old generation collection.
This option automatically enables
-XX: + useparallelgc.
Supported by: 1.5.0.6
-XX: parallelgcthreads = <number>
Specifies the number of threads used in parallel garbage collection when
-XX: + useparallelgc is set. By default a system with N CPUs uses N garbage collection threads.
Example:
-XX: parallelgcthreads = 4
Supported by: 1.4.1, 1.5
-XX: maxgcpausemillis = <MS>
Instructs the VM to try to keep garbage collection pauses shorter than the specified value in ms.
This option applies in conjunction
-XX: + useparallelgc and has higher priority
-XX: gctimeratio.
Example:
-XX: maxgcpausemillis = 10
Supported by: 1.5
-XX: gctimeratio = <ratio>
Sets a throughput goal for the VM. The ratio of garbage collection time to application time is1/(1 + <ratio> ).
This option applies in conjunction
-XX: + useparallelgc and has lower priority
-XX: maxgcpausemillis.
Example:
-XX: gctimeratio = 19 sets a goal of 5% of the total time
Garbage collection.
Supported by: 1.5
-XX: + useadaptivesizepolicy
Instructs the VM to keep track of some statistics and resize both the young and the old (Tenured) Generation Based on the collected data.
This feature is on by default when the option
-XX: + useparallelgc is used.
Supported by: 1.4.1, 1.5
-XX: + aggressiveheap
Instructs the JVM to push memory use to the limit. it inspects the machine resources (size of memory and number of processors) and attempts to set varous parameters to be optimal for long-running, memory allocation-intensive jobs. this option is recommended
For dedicated server machines.
The physical memory on the machines must be at least 256 MB before aggressiveheap can be used.
Beginning with JVM 1.3.1 _ 02 some GC activity is done in parallel.
Beginning with JVM 1.4 This option implies
-XX: + useparallelgc and
-XX: + useadaptivesizepolicy.
Supported by: 1.3, 1.4, 1.5
-XX: + useconcmarksweepgc
Use concurrent garbage collection. This collector is also referred to as
ConcurrentLow pause collector. It collects garbage in the old (Tenured) generation concurrently to executing the application.
Note that this option can not be used in conjunction
-XX: + useparallelgc. Instead you may combine it
-XX: + useparnewgc
Supported by: 1.4.1, 1.5
-XX: + cmsparallelremarkenabled
If
-XX: + useparnewgc option is in use the remark pauses may be decreased with
-XX: + cmsparallelremarkenabled option.
Supported by: 1.4.1, 1.5
-XX: + useparnewgc
Instructs the VM to use a parallel collector for the young generation. This option shocould be used in conjunction
-XX: + useconcmarksweepgc.
Supported by: 1.4.1, 1.5
-XX: + usetraingc
Activates the train garbage collector. Note that development for this collector has been stopped since 1.4.2.
See-xincgc
Supported by: 1.3, 1.4, 1.5
-Xincgc
Activates the incremental (also called Train) garbage collector.
See-XX: + usetraingc
Supported by: 1.3, 1.4, 1.5
Miscellaneous settings
-XSS <value>
Sets the size of the stack. In a server system with specified threads lowering the stack size may be advantageous to reduce footprint. If the stack is too small, you will start seeingstackoverflowerrors.
You may use K, M and G for kilobyte, megabyte and Gigabyte.
Example:
-Xss128k sets the stack size to 128kb
Supported by: 1.3, 1.4, 1.5
-XX: + disableexplicitgc
Disables callto java. Lang. system. GC ().
-XX: softreflrupolicymspermb = <Ms per MB>
Sets the rate at which the VM clears soft references. The rate is expressed in MS per free MB of heap. For the server VM free heap means
PotentiallyFree heap using the maximum heap size as set
-Xmx In the calculation. For the client vm The free heap is calculated using the actual current heap size.
Example:
-XX: softreflrupolicymspermb = 1000 instructs the VM to allow
Softly reachable objects to remain alive for 1 s per free MB
Supported by: 1.3.1, 1.4, 1.5
Server-class Machine
Java 5.0 (1.5) defines a class of machines referred to as server-class machines. these are machines that have 2 or more physical processors and 2 or more GB of physical memory. on server-class machines the Sun JVM starts with altered default settings. these
Are:
-Server-XX: + useparallelgc
Additionally the initial heap size (
-XMS) is set to 1/64 of the physical memory, up to 1 GB. The maximum heap size (
-Xmx) is set to 1/4 of the physical memory, up to 1 GB.
Note that on server-class 32bit-windows systems the VM will nevertheless start with the classic client settings, as most 32bit-windows Java applications are not server applications.
IBM JVMs
Disclaimer: Please note that the data presented in this document has been gathered from several publicly available sources. it is a conscious selection of available VM parameters and even though we tried to check most of the facts presented this document
May contain errors. Also note that the semantics of some of these parameters are different when used with IBM's resettable JVM for the Z/OS platform.
Printing information about GC
-Verbose: GC
Prints out information about garbage collections to standard out.
See-xverbosegclog
Supported by: 1.3.1, 1.4.1, 1.4.2
-Xverbosegclog: <path to File> <FILENAME [, X, Y]>
Prints out information about garbage collections to a file. If the integers x and y are specified, the output is redirected to X Files each containing output from y GC cycles.
See-verbose: GC
Supported by: 1.4.1, 1.4.2
Sizing heap and generations
-Xmx <value>
Overall maximum heap size. You may use K, M and G for kilobyte, megabyte and Gigabyte.
Example:
-Xmx256m sets the maximum heap size to 256 MB
Supported by: 1.3.1, 1.4.1, 1.4.2
-XMS <value>
Overall minimum heap size. You may use K, M and G for kilobyte, megabyte and Gigabyte.
Example:
-Xmx256m sets the minimum heap size to 256 MB
Supported by: 1.3.1, 1.4.1, 1.4.2
-Xinitsh <value>
Sets the initial size of the System Heap. classes in this heap exist for the lifetime of the JVM. the system heap is never subjected to garbage collection. the maximum size of the system heap is unbounded. you may use K, M and G for kilobyte, megabyte and
Gigabyte.
Example:
-Xinitsh256m sets the minimum System Heap size to 256 MB
Supported by: 1.3.1, 1.4.1, 1.4.2
-Xmaxf <value>
This is a floating point number between 0 and 1, which specifies the maximum percentage of free space in the heap. the default is 0.6, or 60%. when this value is set to 0, heap contraction is a constant activity. with a value of 1, the heap never contracts.
You may use K, M and G for kilobyte, megabyte and Gigabyte.
Example:
-Xmaxf0.6 specifies that the heap will be contracted if more
Then 60% of the heap are unused.
Supported by: 1.3.1, 1.4.1, 1.4.2
-Xminf <value>
This is a floating point number between 0 and 1, which specifies the minimum percentage of free space in the heap. the default is 0.3, or 30%. the heap grows if the free space is below the specified amount. you may use K, M and G for kilobyte, megabyte and
Gigabyte.
Example:
-Xminf0.3 specifies that the heap will be grown if less
Then 30% of the heap are unused.
Supported by: 1.3.1, 1.4.1, 1.4.2
Choosing and refreshing a collector
-Xgcpolicy: <optthruput | optavgpause | subpool>
Note that the subpool option was introduced in version 1.4.1 service refresh 1 for AIX only.
Setting gcpolicy to optthruput disables concurrent mark. if you do not have pause time problems (as seen by erratic application response times or by analysis of the verbose GC output), You shocould get the best throughput with this option. optthruput is the default
Setting.
Setting gcpolicy to optavgpause enables concurrent mark with its default values. if you are having problems with erratic application response times that are caused by normal garbage collections, you can remove those problems at the cost of some throughput when
Running with theoptavgpause option.
Setting gcpolicy to subpool enables specify object allocation that aims to achieve better performance in allocating objects on the heap. This setting might provide additional throughput optimization because it can improve the efficiency of object allocation
And reduce lock contention on large SMP systems. Concurrent mark is disabled when this policy is enabled.
Supported by: 1.3.1, 1.4.1, 1.4.2
-Xgcthreads <n>
Sets the total number of threads that are used for garbage collection. On a system with N processors, the default setting is N.
Supported by: 1.3.1, 1.4.1, 1.4.2
-Xcompactgc
Compacts the heapEveryGarbage collection cycle. The default is false (that is, the heap is not compacted). This is not recommended.
Supported by: 1.3.1, 1.4.1, 1.4.2
-Xnocompactgc
NeverCompact the heap. Default is false.
Supported by: 1.3.1, 1.4.1, 1.4.2
-Xnoclassgc
Disables class garbage collection.
Supported by: 1.3.1, 1.4.1, 1.4.2
Miscellaneous settings
-XSS <value>
Sets maximum native stack size for any thread.
You may use K, M and G for kilobyte, megabyte and Gigabyte.
Example:
-Xss128k sets the stack size to 128kb
Supported by: 1.3.1, 1.4.1, 1.4.2
-Xoss <value>
Sets maximum java stack size for any thread.
You may use K, M and G for kilobyte, megabyte and Gigabyte.
Example:
-Xoss128k sets the stack size to 128kb
Supported by: 1.3.1, 1.4.1, 1.4.2
-Xcompactexplicitgc
Runs full compaction each time Java. lang. system. GC () is called. its default behavior with ajava. lang. system. GC () call is to perform a compaction only if an allocation failure triggered a garbage collection since the last Java. lang. system. GC () call.
Supported by: 1.4.1, 1.4.2
-Xnocompactexplicitgc
Never Runs compaction when Java. lang. system. GC () is called. its default behavior with ajava. lang. system. GC () call is to perform a compaction only if an allocation failure triggered a garbage collection since the last Java. lang. system. GC () call.
Supported by: 1.4.1, 1.4.2
-Xdisableexplicitgc
Converts Java application callto java. Lang. system. GC () into no-ops.
Supported by: 1.4.1, 1.4.2