Sunday, August 14, 2011

Garbage Collection What ? Y ? How ?



When a Java object becomes unreachable to the program, then it is subjected to garbage collection. The main use of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused.



Montior GC in OACoreGroup.X.stdout log files to tune the JVM heaps (-Xmx and –Xms) accordingly.

Log entries when running with –XX:+PrintGCTimeStamps option are:

52.250: [Full GC 100053K->34603K(519488K), 2.9323533 secs]
380.674: [GC 188843K->39516K(519488K), 0.4440873 secs]
615.363: [Full GC 37508K->37422K(519488K), 1.7572831 secs]
701.094: [GC 191662K->40146K(519488K), 0.1742931 secs]

T1 : [ Full GC A->B(C), T2 secs ]
T3 : [ GC P->Q(R), T4 secs ]

T1 - Timestamp in seconds, since the JVM started
T3-T1 - Gives number of seconds between garbage collections
A  - Heap size before the GC
B  - Size after the GC was executed
(C) - Current heap size

How to Analyse :

Minor GCs should be spread out far enough so most objects have died and can be collected.
Frequent GCs indicate that you may need to increase your heap size.


UR's Key Run ;-) 

No comments:

Post a Comment