Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the origin of the term "heap" for the free store?

Tags:

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 the data segment, I can't really think of a good reason, especially since it has very little to do with the heap data structure.

Note: Quite a few people mentioned that it's just a whole bunch of things that are kind of unorganized. But to me the term heap physically means a bunch of things that are physically dependent on one another. You pull one out from underneath, everything else collapses on it, etc. In other words, to me heap sounds loosely organized (e.g., latest things are on top). This is not exactly how a heap actually works on most computers, though if you put stuff towards the beginning of the heap and then grew it I guess it could work.

like image 884
Uri Avatar asked Mar 19 '09 02:03

Uri


People also ask

Why is it called a heap?

It is called heap because it is a pile of memory space available to programmers to allocate and de-allocate.

Is free store the same as heap?

In practice, however, they are almost always the same region of memory -- in most cases if you dig into the compiler's implementation of new , you'll find it calls malloc() . In other words: from the machine's point of view, heap and free store are the same thing.

What is heap store?

The heap is a memory used by programming languages to store global variables. By default, all global variable are stored in heap memory space. It supports Dynamic memory allocation. The heap is not managed automatically for you and is not as tightly managed by the CPU.

Is heap memory really a heap?

A memory heap is called a heap in the same way you would refer to a laundry basket as a "heap of clothes". This name is used to indicate a somewhat messy place where memory can be allocated and deallocated at will.


1 Answers

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)

like image 198
Bill the Lizard Avatar answered Oct 19 '22 19:10

Bill the Lizard