Java Memory allocation
A: Stack stores local variables
B: Heap Storage for all new
C: Method Area (in-memory of the method area)
When class loads, the method information is stored in a piece of memory called the method area, and is not stored in the heap with the object as you create it;
D: Local Method Area (System-dependent)
E: Register (CPU use)
Attention:
A: A local variable is defined in the method definition or on a method declaration.
B: The difference between stack memory and heap memory
Stack: When the data is used, it disappears. ------> Store a value type
Local variables: in the stack
Heap: Every new thing that comes out has an address---------> stores a reference type
Member variables: in the heap
Each variable has a default value
Byte,short,int,long 0
float,double 0.0
Char ' \u0000 '
Boolean false
Reference type NULL
After the data is used, it is recycled when the garbage collector is idle.
memory allocation in Java