HotSpot Generations
Java HotSpot memory is mainly divided into three generations.
1) Young Generation
Mostly all the new objects are taking place into the young generation.
In young generation there are areas called Eden and Survivor Spaces.
Mostly all objects are getting place into Eden area. Here the Survivor space hold those objects which survive for at least one collection cycle in Eden area.
Obejcts into Survivor space get one more chance to die before moving into the Old generation.
2) Old Generation
Those objects which survive for some numbers of Collections Cycle in young generation are promoted to old generation.
Also some objects which quite larger than some size are directly take place into Old Generation.
3) Permanent Generation
Permanent generation contains the obejcts which describe the classes and methods as well as the methods and classes themselves.
Note:
Mostly the young generation is collected first using the collection algorithm designed for that generation. After that the OLD generation is collected using the Specific algorithm for that generation. but Sometimes the OLD generation is full enough and it cannot accept the objects from the young generation.
So, in such case the Young generation is not collected first, but instead OLD generation collection algorithm is used on the entire heap space.