Java memory model - the difference between stack and heap
Others
2019-07-24 04:33:09
views: null
A difference: memory allocation strategy (three kinds)
- Static memory: determines the storage space requirements for each data object at runtime compilation. Fixed spatial allocation at compile time, it does not allow nested / recursive code.
- Stack storage: a data area needs compile time is unknown, the run -time module determines the size of the inlet.
- Storage stack: compile time or run time, the module can not determine the size of the inlet, dynamic allocation. For example: a variable-length string or object instance
Difference between the two:
- Management: Heap need to GC, the stack is automatically released
- Space: heap> Stack
- Related debris: fragments generated far less than the stack heap fragmentation generated
- Allocation: stack supports static / dynamic allocation; heap only supports dynamic allocation
- Efficiency: Efficiency Stack> heap efficiency
Origin www.cnblogs.com/starstarstar/p/11234333.html