7.1.3 Relation between the occurrence of garbage collection and memory space
A garbage collection occurs in accordance with the usage of the memory space. This subsection describes the times at which a garbage collection occurs
- Note
- If you use the RMI to register and reference a remote object, a garbage collection might occur periodically. You can specify the timing for garbage collection in milliseconds in one of the following properties. The default value is 3600000 milliseconds (1 hour).
- sun.rmi.dgc.client.gcInterval property
- sun.rmi.dgc.server.gcInterval property
- To change the time at which a garbage collection will occur, specify any value in milliseconds in one of the properties. Note that you can specify a value in the range from 1 to Long.MAX_VALUE-1. For details, see the relevant page (http://download.oracle.com/javase/6/docs/technotes/guides/rmi/sunrmiproperties.html).
- Organization of this subsection
- (1) Timing of occurrence of copy garbage collection
- (2) Timing of occurrence of full garbage collection
(1) Timing of occurrence of copy garbage collection
A copy garbage collection occurs at the following timings:
- When there is insufficient space for allocation of the Eden area
- When the -copygc option is specified in the jheapprof command and executed
(2) Timing of occurrence of full garbage collection
A full garbage collection occurs at the following timings:
- When the memory size being used in the New area (total of the Eden area and the Survivor area) exceeds the unused memory size for maximum value of the Tenured area, and the free space for allocation to the Eden area is insufficient
- Note
- A full garbage collection is not required to occur at the above timing. In such cases, JavaVM determines whether to initiate a full garbage collection based on the following values:
- The average value is weighed and calculated according to the time when the copy garbage collection occurred for the objects moved from the New area to the Tenured area during a past copy garbage collection
- When an attempt to move objects from the New area (total of the Eden area and the Survivor area) to the Tenured area fails as a result of copy garbage collection
- When there is an allocation request of memory size (size of Java object) that exceeds the individual unused memory size of the New area and the Tenured area
- When one of the following occurs as a result of the copy garbage collection:
- When the unused memory size of the allocated Tenured area falls below 10,000 bytes
- When the allocated Tenured area is extended due to the transfer of objects to the Tenured area during the copy garbage collection
- When the java.lang.System.gc() method is executed
- When the memory size to be allocated to the Permanent area exceeds the unused memory size of the allocated Permanent area.
- When the javagc command is executed.
- When the jheapprof command is executed.
Ensure that mainly above step 1 and step 3 do not occur while JavaVM is being tuned.
- Reference note
- You can use the extended verbosegc information for checking the occurrence factors of the full garbage collection. For details about how to check the factors for occurrence of full garbage collection, see 7.9 How to analyze the factors of a full garbage collection using the extended verbosegc information.