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

前端 未结 9 1537
暖寄归人
暖寄归人 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:49

    I don't know if it is the first but ALGOL 68 had keyword 'heap' for allocating memory from the free memory heap.

    The first use of 'heap' is likely to be found somewhere between 1958, when John McCarthy invented garbage collection for Lisp and the development of ALGOL 68

    0 讨论(0)
  • 2020-12-01 08:50

    Knuth rejects the term "heap" used as a synonym for the free memory store.

    Several authors began about 1975 to call the pool of available memory a "heap." But in the present series of books, we will use that word only in its more traditional sense related to priority queues. (Fundamental Algorithms, 3rd ed., p. 435)

    0 讨论(0)
  • 2020-12-01 08:52

    Heap usually has these features:

    1. You can't predict the address of a block malloc() returns.

    2. You have no idea of how the address returned by the next malloc() is related to the address of the previous one.

    3. You can malloc() blocks of variable sizes.

    So you have something that can store a bunch of blocks of variable sizes and return them in some generally unpredictable order. How else would you call it if not "heap"?

    0 讨论(0)
提交回复
热议问题