What is the origin of the term “heap” for the free store?

前端 未结 9 1541
暖寄归人
暖寄归人 2020-12-01 08:23

I am trying to find the official (or a good enough) reason that the free store is commonly referred to as the heap.

Except for the fact that it grows from the end of

9条回答
  •  醉梦人生
    2020-12-01 08:31

    It's named a heap for the contrasting image it conjures up to that of a stack.

    • In a stack of items, items sit one on top of the other in the order they were placed there, and you can only remove the top one (without toppling the whole thing over).

      Stack like a stack of papers

    • In a heap, there is no particular order to the way items are placed. You can reach in and remove items in any order because there is no clear 'top' item.

      Heap like a heap of licorice allsorts

    It does a fairly good job of describing the two ways of allocating and freeing memory in a stack and a heap. Yum!

提交回复
热议问题