Saturday, October 31, 2009

Java Memory Arrangements

Java Memory Arrangements

Java Memory is splitted in to three generation - Young Generation, Tenured Generation, and Permanent Generation.

  • Young Generation

    Infant mortality data are get stored in young generation, means any new objects created and stored here. This has One Eden and two survivor spaces, where one survivor space always empty. If data get filled in survivor space and ready to long live then it will be copied to Eden space. Usually in Solaris, two equal space alotted for eden and survivorspace.

    Once the Eden space get filled then Minor Collections(Garbage Collections) get triggered and tenured objects will be copied to Tenured Generation.

    Specifying bigger young generation for the application which does have more infant moratality objects, would give better performance.

  • Tenured Generation

    Long live tenured objects will be stored in this space. Once the Tenured generation get filled then Major collections(Garbage Collections) will be triggered. This collection costs more, because of the fact that it will operate on all long living objects. In general, keeping more space for long running applications like Application Server , would result better performance.

    Major and Minor collections happened based on the tuning parameters set. In general, 40% of Heap(-Xmx) filled then major collections starts and shrinks up to -Xms value. This percentage can be reset using -XX:MinHeapFreeRatio. If the application shrinks and expands the memory allocation (malloc) then this will cost the performance. Hence, this has to be controlled and set using -XX:MaxHeapFreeRatio to some percentage, which always application needed size in the entire tenure.

    Keeping -Xms and -Xmx value equal will result better performance for GUI, and server applications.

  • Permanent Generation

    Loaded classes and Classe definitions are get stored in this space. In general, this space will be occupied in physical memory while application start up based on the value of -XX:PermSize. Maximum size permanent generation space can be set by -XX:MaxPermSize.

    If the application has more number of classes and object has to be created/loaded at the given point of time then this space has to be set high. Even this property helps to improve the performance and avoids OutOfMemoryError, which comes for PermGen space full.

Java Application Memory= Heap + PermGen Space.

In JRocket, there is no concept of PermGen Space. Hence, JRocket users no need of worrying about these properties.

Reactions:

0 comments:

Post a Comment

Recent Posts

Unix Commands | List all My Posts

Texts

This blog intended to share the knowledge and contribute to JAVA Community such a way that by providing samples and pointing right documents/webpages. We try to give our knowledege level best and no guarantee can be claimed on truth. Copyright and Terms of Policy refer blogspot.com

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More