Java memory Division:
In Java memory allocation, Java divides the memory into: Method Area, heap, virtual machine stack, local method stack,ProgramCounter. The method zone and heap share all threads, while the Virtual Machine stack and the local method Stack also have program counters that isolate threads. Each region has its own creation and destruction time.
Program counter:
It is the row number indicator of the byte executed by the current thread. Java multithreading is implemented by switching threads in turn and allocating the processor execution time. Therefore, in order for each thread to be able to return to the correct position after switching, each thread needs an independent program counter.
Java Virtual Machine Stack:
Each stack frame is created during execution to store information such as the local variable table, operand stack, dynamic link, and method exit. The Virtual Memory stack is the "stack" we often talk about ". The memory required for the local variable table is allocated during the compilation period.
Local method Stack:
Similar to the Virtual Machine stack, the difference is that the virtual machine stack executes Java method services for the virtual machine, while the local method stack uses native method services for the virtual machine.
Java heap:
Shared by all programs and created when the VM is started. This memory area is used to store object instances. According to Java Virtual Machine regulations, Java heap can be physically discontinuous memory space, as long as the logic is continuous.
Method Area:
Same as the heap, it is shared among various threads. The function is to store information about classes loaded by virtual machines, constants, static variables, and compiled by the real-time compiler.CodeAnd other data.
Runtime frequent volume pool:
Is part of the method area. The function is to store various literal and symbolic references generated during the compilation period.