All the data and programs are stored in the running data area, it includes the following parts: Stack stack is called the stack memory, is the Java program's runtime, is created when the thread is created, its life is the life of the following threads, thread end stack memory is released, there is no garbage collection problem for the stack, As soon as the thread is finished, the stack is over. The question is: What data is stored in the stack? And what is the format? The data in the stack is in the format of stack frame, the stack frame is a memory block, is a data set, is a data set about method and run-time data, when a method A is called, it generates a stack frame F1, and is pressed into the stack, a method calls the B method , the resulting stack frame F2 is also pressed into the stack, after execution, the first pop-up F2 stack frame, and then pop F1 stack frame, follow the "advanced after out" principle. What data is there in the stack frame? The main storage of the stack frame is 3 kinds of data: local variables (locally Variables), including input parameters and output parameters as well as variables within the method, stack operation (Operand stack), record stack, stack operation, stack frame data, including class files, methods and so on. Heap heap Memory There is only one heap class stored in a JVM instance, and the size of the heap memory can be adjusted. After the class loader reads the class file, it is necessary to put the class, method, and constant variables into the heap memory to facilitate execution of the executor, and heap memory is divided into three parts: Permanent Space Permanent storage is a resident memory area that is used to store the class that is carried by the JDK itself. Interface metadata, that is, it stores the required class information in the runtime environment, the data that is loaded into this area will not be reclaimed by the garbage collector, and the memory that is occupied by this zone will be freed by shutting down the JVM. Young Generation Space Renaissance District is the birth, growth, extinction area of a class where a class is generated, applied, and finally collected by the garbage collector to end life. The new district is divided into two parts: Eden Space and the Survivor area (Survivor Pace), all of which are new in the Eden District. There are two surviving areas: the 0 area (Survivor 0 space) and the 1 zone (Survivor 1 space). When the space in Eden is exhausted, the program needs to create objects, and the JVM's garbage collector will garbage reclaim the Garden of Eden and destroy objects in the Eden area that are no longer referenced by other objects. The remaining objects in the Garden of Eden are then moved to the surviving zone 0. If the surviving zone 0 is full, then the area will be garbage collected and then moved to Zone 1. What if the 1 districts are full? Then move to the retirement area. [Img=450,346]file:///c:\uSers\thinkpad\appdata\local\temp\ksohtml\wps_clip_image-3207.png
The method area method zone is shared by all threads, and the region holds all the fields and method bytecode, as well as some special methods such as constructors, where the interface code is defined. PC Register Program counter each thread has a program counter, which is a pointer to the method byte code in the method area, which reads the next instruction from the execution engine. Native method Stack Local methods stack
Memory management of the JVM