JVM memory will be divided into separate parts like Heap memory, Stack Memory and PermGene.
Here Heap memory again divided into two parts Old Generation and Young Generation.
Here Young Generation again is divided into two parts Eden memory and two parts Survivor Memory.
Young Generation:
1. All objects which we are created will store in Young Generation and Most of these will store inside Eden Memory.
2. Garbage collector will perform once Young Generation is filled and we call this GC as Minor GC.
3. When Eden space is filled, Minor GC will perform and all survivor objects will be moved to one of survivor space. Hence at a time one of the survivor space is empty.
4. Objects which are still survived after many minor GC will be moved to OLD Generation of Heap memory.
Old Generation:
1. Objects which are long lived and survived after minor GC will be stored in Old Generation.
2. GcC will perform once old generation is full and we call it as Major GC. This GC will take long time.
Permanent Generation(Perm Gene):
1. It is not part of heap memory and it contains application metadata required by JVM which describes classes and methods used in application.
2. PermGene will be generated by JVM at runtime based on class in application.
3. Perm Gene also contains Java SE library classes and methods.
4. Objects of Perm Gene will be garbage collected during full Garbage collection.
Method Area:
It is part of Perm Gene to store the static variables and runtime constants ,constructors, class structures and code for methods.
Memory Pool:
It is created by JVM memory to create pool of immutable objects. String pool memory is best example of memory pool.
Memory pool will be part of either Heap or Perm Gene based on JVM memory manager implementation.
By using below arguments we can customize the memory when JVM starts:
1. -Xmx -- to set maximum heap size
2. -Xms -- to set minimum heap size
3. -Xmn -- to set space for young Generation.
4. -XX:PermGen ---to set initial size for Permanent Generation.
5. -XX:MaxPermGen --- to set maximum size for Permanent Generation.
Stack Memory:
Stack memory will create per every thread and it contains local variables, method calls and reference of objects in hep that are getting referred will be stored in stack memory.
Garbage Collection in Java :
1. GC is the process of identifying unused objects and delete from memory and free space will be allocated to newly created objects in future.
2. Java has automatic GC and it is one of good feature of Java(some other languages use manual process to allocate and deallocate space).
3. It is program which runs in background to get all objects from meory and idenity ibjects which does not have any reference from any part of program and delete all un referenced objects and allocate free space for newly created objects.
GC follow three basic steps:
1. Marking --- Identifying the objects which are unused and used by program.
2. Normal Deletion : GC removes the un used objects and make space available for newly created objects.
3. Deletion with compacting : GC will move all survived objects together once it removes the un used objects. This will increase performance to allocate memory to new objects.
Here Heap memory again divided into two parts Old Generation and Young Generation.
Here Young Generation again is divided into two parts Eden memory and two parts Survivor Memory.
Young Generation:
1. All objects which we are created will store in Young Generation and Most of these will store inside Eden Memory.
2. Garbage collector will perform once Young Generation is filled and we call this GC as Minor GC.
3. When Eden space is filled, Minor GC will perform and all survivor objects will be moved to one of survivor space. Hence at a time one of the survivor space is empty.
4. Objects which are still survived after many minor GC will be moved to OLD Generation of Heap memory.
Old Generation:
1. Objects which are long lived and survived after minor GC will be stored in Old Generation.
2. GcC will perform once old generation is full and we call it as Major GC. This GC will take long time.
Permanent Generation(Perm Gene):
1. It is not part of heap memory and it contains application metadata required by JVM which describes classes and methods used in application.
2. PermGene will be generated by JVM at runtime based on class in application.
3. Perm Gene also contains Java SE library classes and methods.
4. Objects of Perm Gene will be garbage collected during full Garbage collection.
Method Area:
It is part of Perm Gene to store the static variables and runtime constants ,constructors, class structures and code for methods.
Memory Pool:
It is created by JVM memory to create pool of immutable objects. String pool memory is best example of memory pool.
Memory pool will be part of either Heap or Perm Gene based on JVM memory manager implementation.
By using below arguments we can customize the memory when JVM starts:
1. -Xmx -- to set maximum heap size
2. -Xms -- to set minimum heap size
3. -Xmn -- to set space for young Generation.
4. -XX:PermGen ---to set initial size for Permanent Generation.
5. -XX:MaxPermGen --- to set maximum size for Permanent Generation.
Stack Memory:
Stack memory will create per every thread and it contains local variables, method calls and reference of objects in hep that are getting referred will be stored in stack memory.
Garbage Collection in Java :
1. GC is the process of identifying unused objects and delete from memory and free space will be allocated to newly created objects in future.
2. Java has automatic GC and it is one of good feature of Java(some other languages use manual process to allocate and deallocate space).
3. It is program which runs in background to get all objects from meory and idenity ibjects which does not have any reference from any part of program and delete all un referenced objects and allocate free space for newly created objects.
GC follow three basic steps:
1. Marking --- Identifying the objects which are unused and used by program.
2. Normal Deletion : GC removes the un used objects and make space available for newly created objects.
3. Deletion with compacting : GC will move all survived objects together once it removes the un used objects. This will increase performance to allocate memory to new objects.
No comments:
Post a Comment