Java GC

Java GC Tutorials, Detailed discussion of Young and Old Generation GC

Ads

Tutorials   
Java final method Assert in Java Final method in java Autoboxing in Java assert In Java JDBC batch insert using Java bean class Java Singleton Pattern Java Collection API - Java Tutorials Stack Overflow - Java Tutorials End of Year Puzzle The link to the outer class,java tutorial,java tutorials Orientating Components Right to Left,java newsletter,java,tutorial Non-virtual Methods in Java - java tutorials Multicasting in Java - java tutorials,tutorial Creation Time Comparison of Multi Dimensional Array- Java Tutorials Making Exceptions Unchecked - java tutorial,java tutorials Making Enumerations Iterable - JDK 5 Example Which is Faster - LinkedList or ArrayList? LinkedHashMap - Java Tutorials HashMap and HashCode JDK 1.4 the NullPointerException - Java Tutorials Java HashMap - Java Tutorials Java GC java awt package tutorial Java Multi Dimensions Array - Java Tutorials Java HashSet  - Java Tutorials Java Field Initialisation - Java Tutorials Java Comments - Java Tutorials J2EE Singleton Pattern - Design Pattern Tutorials Java - JDK Tutorials garbage collection in java Final Methods - Java Tutorials Exceptional Constructors - Java Tutorials Double-checked locking,java tutorials,java tutorial Disassembling Java Classes - Java Tutorials Java Deadlocks - Java Deadlocks Tutorials, Deadlocks in Java Commenting out your code - Java Tutorials Class names don't identify a class - Java Tutorials Causing Deadlocks in Swing Code Exception in Java - Java Tutorials Catching Exceptions in GUI Code - Java Tutorials boolean comparisons - tutorial Interthread Communication in Java BASIC Java - Java Tutorials Thread Deadlocks - Java Tutorials Autoboxing unboxing in Java - Java Tutorials Assertion in Java Appending Strings - Java Tutorials Anonymous Inner Classes - Anonymous Inner Classes tutorial Assertion in java
Ads

Major/Minor GC in Java

In this Section you will learn the type of GC or garbage collection in Java.

In java, objects are dynamically allocated using new() keyword. But the key question is what happened to these objects when they have no use. How these objects are destroyed for later reallocation of their memory. In java this is done automatically through garbage collection. In other words it deallocate memory automatically which have no longer use. This technique is known as Garbage Collection.

In this way, java ensures that sufficient memory will available to your program. It (Garbage Collection) is controlled by the configuration parameters of the heap.

Note: Heap resides in the physical memory which is incorporated by the Java Virtual Machine(JVM) for the creation of  objects. The configuration parameter of the heap are Xms & Xmx. You can use these configuration parameter as :

java ?Xms:256m Xmx:1g

It points that the Xms(minimum heap size) is 256Mb & Xmx(Maximum heap size) is !024Mb.

Types of Garbage Collection(GC)

The garbage collection is of two types :

  • Major
  • Minor

Before understanding Major/Minor GC, first you need to understand young generation.

Young Generation :

The temporary objects which are ,initially, not fully garbage collected. When these young generation become old, they become part of the old generation. Old generation is known as Minor GC. When Minor GC become fully garbage collected, it is known as Major GC.

How To Check Major/Minor GC

You can check the Major/Minor GC as follows :

To check the Major/Minor GC , you need to start your application as follows :

java ?verbose:gc HelloWorld

The Output of the above should be like this :

GC 325407K->83000K(776768K), 0.2300771 secs

  • GC : This tells us that it is a minor collection. If it is Full GC  then it tells us that it is a major collection.
  • 325407K ? The combined size of live objects before garbage collection.
  • 83000K ? The combined size of live objects after garbage collection. 
  • (776768K) ? the total available space, not counting the space in the permanent generation, which is the total heap minus one of the survivor spaces. 
  • 0.2300771 secs ? time it took for garbage collection to occur.

Advertisements

Ads
Share on Google+Share on Google+

Java GC

Posted on: April 18, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: Java GC  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads