当前位置:网站首页>The difference between heap and stack

The difference between heap and stack

2022-07-05 04:55:00 yaohuiyaoo

1. What is stack?

Stack is an ordered memory array .

2. The stack can store the value of variables , The execution environment of the program , Parameters passed to method

3. Data can only be inserted and deleted from the top of the stack , Put the data on the top of the stack for stacking , Delete the data as out of stack

4. What is a heap

Disordered memory area of heap , It can be deposited and removed in any order , although Can save data , But it cannot be explicitly deleted .

Heap is different from stack

1. Stack can save code execution steps , The heap holds objects , Data etc.

2. The stack allocates memory space during compilation ; Heap allocates memory size according to program operation

3. The stack has the principle of first in, last out , And it is a continuous memory area ; The heap is disordered , A piece of discontinuous , Controlled and released by the user

原网站

版权声明
本文为[yaohuiyaoo]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140626298820.html