- The Java heap is used to hold object examples, related to data, and the Java stack is primarily related to thread function calls
- function calls once in and out of the Java stack, call the time of the stack, call end (return or throw) out of the stack, function parameters and function Local variables are stored in the stack frame, so the function call after the stack frame is ejected, the corresponding local variables will be invalidated.
- The more function arguments and local variables, the larger the table of local variables that need to be saved in the stack frame, and the fewer levels of function calls.
- Local variables are important root nodes of garbage collection, and any objects that are referenced directly or indirectly by local variables are not recycled.
- For non-escaping objects, the virtual machine can perform memory allocation optimizations to allocate these objects on the stack.
- Allocations on the stack depend on the implementation of escape analysis and variable substitution.
- The method area is shared by all threads, used to save classes, classes of methods, classes of variables, etc., in JDK1.6 and JDK1.7, the method area is the permanent zone, in JDK1.8, the permanent zone has been completely removed and replaced by the metadata area.
The basic structure of a Java virtual machine