Jvm Heap Heap (six)

  1, Heap (before Java7)

    Jvm there is only one instance of a memory heap, the memory heap size can be adjusted. After adding the class read a class file, you need to classes, methods, variables often into the heap memory, hold true for all reference types of information to facilitate the implementation of the actuator.

    Heap memory logically divided into three parts: a permanent neonatal + + Aged

          

    Shinsei District

    Freshman class district is born, growing, dying area, where a class is generated, application, and finally collected the garbage collector, the end of life. Freshmen area is divided into two parts: Eden District (Eden Space) and the fortunate survivors zone (Survivor Space) , all classes are out in the new Eden area. Komura area has two: Zone 0 (0 Survivor Space ) and District 1 (Survivor 1space). When Eden running out of space, the program and the need to create an object, Jvm garbage collector will Eden area for garbage collection ( Minor GC ), the target area in the Garden of Eden is no longer referenced by other objects were destroyed. Eden region then move the object to the remaining surviving 0 region. If the area is also full of survivors 0, then the garbage collection area, then moved to Zone 1. What if Zone 1 is also full of it? Then move to the pension area. If the pension area is also full, so this time will produce MajorGC (FullGC), for memory clean up the pension area. If the pension area after the implementation of the Full GC found that the object still can not be saved, it will have OOM abnormal "OutOfMemoryError".

  If java.lang.OutOfMemoryError appears: Java heap space anomaly, indicating that the Java virtual machine memory is not enough. There are two reasons:

  (1) Java Virtual Machine heap memory settings is not enough, you can adjust the parameters -Xms, Xmx.

  (2) the code to create a large number of large objects, and for a long time can not be garbage collected (there is referenced)

 From the perspective of Java heap GC it can also be broken down into: the new generation (Eden District, From Survivor To Survivor district and region ) and the old era.

  

                                                   MinorGC process (replication -> Clear -> interchangeable), wherein, Eden: From: To = 8: 1: 1

  1: eden, SurvivorFrom copied to survivorTo, ages +1

  First, copy the Eden area and SurvivorFrom surviving objects to SurvivorTo area (if there is to the age and older met the criteria, then assigned to the district's old), while the age of these objects +1 (if the location is not enough SurvivorTo to put tenured)

   2: Empty eden, SurvivorFrom

  Then, remove the objects of Eden and SurvivorFrom

  3: SurvivorTo and SurvivorFrom swap

  Finally, SurvivorTo and SurvivorFrom swap, the original SurvivorTo becomes the next GC SurvivorFrom area

  

  In practical terms, the method area (Method Area) and the heap, is shared by the threads of each content area, for storing a virtual machine loading: common variable class information + + + static variables the compiler code, etc., although JVM specification will be described as a method of zone logic portion of the stack, but it also has an alias named non-heap (non-heap), and the purpose is to separate the stack .

    For the HotSpot virtual machine, many developers accustomed to the method area called the "permanent-generation (Parmaneng Gen)", but said the difference between the two on the strict nature, or permanent generations to implement the method area only, on behalf of a permanent method area ( is an interface corresponding to interface) of an implementation version jdk1.7, it has been permanently on behalf of the original string constant pool removed.

Guess you like

Origin www.cnblogs.com/houstao/p/11521487.html