table of Contents
3, explain the memory stack (stack), the use of the heap (heap) and static area (static area) of
4, Perm Space saved what data? Cause OutOfMemory it?
7, describe the principle mechanism JVM class document loading?
9, the life cycle of the class [loading]
10, Java will be a memory leak it, please describe simple.
11, GC is the What? Why should there be GC?
12, doing GC, order ⼀ objects to be moved in various Space memory, what is?
13, which garbage collection algorithm you know?
15, how to determine whether an object should be recovered
16, permanent behalf of the JVM garbage collection will happen?
21, Minor GC and Full GC, respectively, when did it happen?
1.jvm memory structure
And p is the method area shared by all threads of memory regions; and java stack, native method stacks and the programmer is running counter thread private memory area.
- Java heap (Heap), is the largest in memory of a Java virtual machine management. Java heap is shared by all threads in a memory area is created when the virtual machine starts. The sole purpose of this memory area is stored object instance, almost all object instances are here to allocate memory .
- District method (Method Area), method area (Method Area) and the Java heap, as each thread is a shared memory area, which is used to store class information has been loaded in the virtual machine, the constant static variable, real-time compiler codes and other data.
- Program counter (Program Counter Register), the program counter (Program Counter Register) is a small memory space, its role can be seen as the row number designator bytecode executed by the current thread.
- JVM stack (JVM Stacks), as the program counter, Java Virtual Machine stack (Java Virtual Machine Stacks) is also a thread private, its life cycle and the same thread. Is a virtual machine stack Java memory model described method of execution: when each method will be executed at the same time create a stack frame (Stack Frame) for storing local variable table, operation information stack, dynamic linking, method exports. Each method is called until the completion of the execution procedure, a stack frame corresponds to a virtual machine from the stack to the stack of a process stack.
- Native method stacks (Native Method Stacks), native method stacks (Native Method Stacks) and virtual machine stacks the role is very similar, but the difference is the virtual machine execution stack for the Java Virtual Machine method (ie bytecode) service, and the local stack method is to use a virtual machine to a native method service
2. Object Allocation Rules
- Objects priority in the allocation area in Eden, Eden zone if there is not enough space, the virtual machine to perform a Minor GC.
- Large objects directly into the old year (large objects are objects requires a large amount of contiguous memory space). The purpose of this is to avoid a large number of memory copy (copy algorithm employed to collect new generation memory) occurs between the region and the two Eden Survivor areas.
- Long-term survival of the object into the old era. Virtual machine definition for each object of an age counter, if the object after 1 Minor GC then the object will enter Survivor areas, after each time through the Minor GC then the age of the subject plus 1, know the object reaches the threshold into old age area.
- Dynamic determine the age of an object. If the sum of the sizes of all objects of the same age Survivor region Survivor greater than one half the space, equal to or older than the age of the subject can directly access the old year.
- Space allocation guarantee. Every time Minor GC, JVM will calculate the average size of the object to move it Survivor elderly area, if this value is greater than the size of the remaining area is aged for a Full GC, if the check is less than the set HandlePromotionFailure, only be true if the Monitor GC, if false then carried Full GC.