iamjerryyeung

Saturday, January 22, 2005

java:garbage collection

http://www-106.ibm.com/developerworks/ibm/library/i-gctroub/

Heapbase marks the base of the heap, while heaptop is the absolute maximum the heap can grow to. The difference, heaptop - heapbase, is decided by the command-line parameter -Xmx. This and other command-line parameters are documented in the developerWorks article on verbosegc and command-line parameters. The heaplimit pointer can go up, when the heap can expand, or down, as the heap shrinks. The heaplimit can never exceed heaptop, and can never go below the initial heap size specified using -Xms. The size of the heap at any time is heaplimit - heapbase.
The heap is expanded when the ratio of free heap to total heap falls below the value specified by -Xminf (minf is the minimum free). It gets shrunk if the ratio of free heap to total heap exceeds the value specified by -Xmaxf (maxf is the maximum free). The defaults for -Xminf and -Xmaxf are 0.3 and 0.6, respectively, so the JVM tries to maintain a heap that is between 30 and 60 percent free at all times. The parameters -Xmine (mine is the minimum expansion size) and -Xmaxe (maxe is the maximum expansion size) control the amount of expansion of the heap. These four parameters have no effect on fixed-size heaps (JVM started with -Xms value equal to -Xmx value, implying HeapLimit = HeapTop), because fixed-size heaps do not expand or shrink.
When a Java thread makes a request for a piece of storage, and the JVM is unable to locate a large enough chunk of storage to satisfy the request, an allocation failure (AF) is said to have occurred. This is when garbage collection becomes unavoidable. Garbage collection involves collecting all the "unreachable" references so that the space consumed by them can be reused. It is carried out by the thread that makes an allocation request, and is a Stop-The-World (STW) mechanism; all other threads of the Java application are suspended while garbage collection is going on (except the garbage collection helper threads).
IBM implementation uses a garbage collection algorithm called mark-sweep-compact (MSC), which is named after three distinct phases.

0 Comments:

Post a Comment

<< Home