- One: Java technology system module diagram
- Two: JVM memory area Model
1. Method Area
Also known as "permanent generation", "non-heap", it is used to store virtual machine loaded class information, constants, static variables, is the memory area shared by each thread . The default minimum value is 16MB and the maximum value is 64MB, which limits the size of the method area through the-xx:permsize and-xx:maxpermsize parameters.
Run a constant pool: is a part of the method area, in addition to the class file has a version of the classes, fields, methods, interfaces, and other descriptive information, there is also a const pool, used to hold the compiler generated a variety of symbol references, which will be placed in the method area after the class loaded in the run constant pool.
2. Virtual machine stack
Describes the memory model that is executed by the Java method: Each method is executed with a "stack frame" that stores information such as the local variable table (including parameters), the Operation Stack, the method exit, and so on. Each method is called to the completion of the process, corresponding to a stack frame in the virtual machine stack from the stack to the process of the stack. The declaration period is the same as the thread and is thread-private .
A local variable table holds the various basic data types known to the compiler (Boolean, Byte, char, short, int, float, long, double), object reference (reference pointer, not the object itself), Where 64-bit long and double-type data takes up 2 local variables, the remaining data types are only 1. The memory space required for a local variable table is allocated during compilation, and when entering a method, this method requires that the local variable allocated in the stack frame is fully deterministic, and the stack frame does not change the size space of the local variable table during the run time.
3. Local method Stack
Similar to the virtual machine stack, the difference lies in the Java method service that the virtual machine stack executes for the virtual machine, while the local method stack serves the native method.
4. Heap
Also known as the Java heap, the GC heap is the largest memory area managed by the Java Virtual machine, and is also the
Since collectors are now using generational collection algorithms, the heap is divided into the new generation and the old age. The new generation primarily stores newly created objects and objects that have not yet entered the old age. The old age stores the objects that survived by several new generation GC (Minor GC).
New generation:
the newly created object of the program is to allocate memory from the Cenozoic, and the Cenozoic is made up of Eden Space and two blocks of survivor space of the same size (usually called S0 and S1 or from and to), which can be specified by the-XMN parameter, or by-XX: Survivorration to adjust the size of Eden space and survivor space.
old age:
for storing objects that have survived through multiple Cenozoic GC, such as cached objects, new objects may also enter the old age, mainly in two cases: ①. Large objects, which can be set by the startup parameter-xx:pretenuresizethreshold=1024 (in bytes , the default is 0) to represent more than when the new generation is not allocated, but directly in the old age distribution. ②. A large Array object that has no reference to the outer object in the tangent array.
older generations accounted for the memory size of-xmx corresponding to the value minus-xmn corresponding value.
5. Program Counter
is the smallest piece of memory area, its role is the current thread executes the byte code of the line number indicator, in the virtual machine model, the bytecode interpreter works by changing the value of this counter to select the next need to execute the byte code instruction, branch, loop, exception handling, Basic functions such as thread recovery need to rely on counters to complete.
Direct memory is not part of the virtual machine memory, nor is it a memory area defined in the Java Virtual Machine specification. The newly added NiO in jdk1.4, which introduces the IO mode of channel and buffer, can call the native method to allocate out-of-heap memory directly, which is the native memory and does not affect the size of heap memory.
Java Virtual machine Learning-Architecture memory model