A preliminary study of JVM (3) method area, stack area

1. Method area

Method area: The Method Area
method area is shared by all threads, all fields, method bytecodes, and some special methods, such as constructors, interface codes are also defined here, in short: all defined method information is stored in this zone, which is a shared zone.

Static variables, constants, class information (construction methods, interface definitions), and runtime constants exist in the method area, but instance variables exist in the heap memory, which has nothing to do with the method area. Summarize:

Second, the stack area

Program = Data Structure + Algorithm (Continuous Learning)

Developers write programs on the market = framework + business logic

The stack memory is responsible for the running of the program, the life cycle and the thread synchronization. When the thread ends, the stack memory is released. There is no garbage collection problem for the stack. Once the thread ends, the stack is Over.

Pop the stack: take the element from the stack area
Push the stack: store the element on the stack

For example, the program first executes the main method, pushes the main() method to the bottom of the stack, pushes the methods to be executed on the stack in order, and pops the stack area after executing a method.

2.1 What data is stored in the stack

Stack: eight basic data types, object references, instance methods

2.2 The principle of stack operation

stack frame:

2.3 Interaction among heap, stack and method area

Leave a Comment

Your email address will not be published. Required fields are marked *