When a Java program runs, it needs to allocate space in memory. In order to improve the efficiency of computing, the space is divided into different regions, because each region has a specific processing data and memory management mode
1, Stack memory
For storing local variables, the occupied space is automatically freed when the data is used.
When the main function runs, it will open up space in the stack, place global variables, etc.
When the main function calls another function, the local variable of the function is also in the stack
2, Heap memory
Arrays and objects, which are stored in heap memory by the instance created by new
Each entity has a memory address value
The variables in the entity have default initialization values
Entities are no longer being used and are reclaimed by the garbage collector for an indeterminate period of time
3, method area, local method area, register (these three kinds later)
Wisdom Podcast Video Notes (i) Partitioning of memory