Why is the main memory for object allocation called the ‘heap’

heapmemoryprogramming-languagesstack

Has anybody got an idea why the area of main memory where objects are allocated is referred to as the heap. I can understand the rationale for that of the stack LIFO but would like to know what the rationale is for the 'heap' name.

Best Answer

From the information found at StackOverflow - What is the origin of the term “heap” for the free store? and Why are two different concepts both called “heap”?

This information at least dates back to Knuth in 1975 referencing other (unnamed) authors:

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. (The Art of Computer Programming - Fundamental Algorithms, 3rd ed., p. 435)

There is also mention of Wijngaarden discussion on Algol in the early 1970s referring to the available memory pool as a heap (heap is a reserved word in Algol which is defined in places as "allocate variable some free space from the global heap." - Algol68 dates from 1968).

Implementing the ALGOL 68 heap from 1970 may be of use in tracking down some aspects of word origin, though much if it is behind a paywall.