Personal Understanding of heap and stack, personal understanding
Heap: (object)
Variables of the reference type, whose memory is allocated to the heap or constant pool (character bed constants and basic data type constants), must be created through new and other methods.
The main function of memory is to store the objects that are created (new.
(It is mainly used to store objects. The access speed is slow and the memory can be dynamically allocated during running. The lifetime does not need to be determined in advance)
STACK: (basic data type variable, object reference variable)
The main function of stack memory is to store basic data types and reference variables. stack memory management is implemented through the stack's "post-in-first-out" mode.
(Mainly used to execute programs. The access speed is fast, the size and survival time must be determined, and there is no flexibility)