C++, Free-Store vs Heap

See http://www.gotw.ca/gotw/009.htm; it can describe the differences between the heap and the free-store far better than I could:

Free-store:

The free store is one of the two dynamic memory areas, allocated/freed by new/delete. Object lifetime can be less than the time the storage is allocated; that is, free store objects can have memory allocated without being immediately initialized, and can be destroyed without the memory being immediately deallocated. During the period when the storage is allocated but outside the object's lifetime, the storage may be accessed and manipulated through a void* but none of the proto-object's nonstatic members or member functions may be accessed, have their addresses taken, or be otherwise manipulated.

Heap:

The heap is the other dynamic memory area, allocated/freed by malloc/free and their variants. Note that while the default global new and delete might be implemented in terms of malloc and free by a particular compiler, the heap is not the same as free store and memory allocated in one area cannot be safely deallocated in the other. Memory allocated from the heap can be used for objects of class type by placement-new construction and explicit destruction. If so used, the notes about free store object lifetime apply similarly here.


For C++, the difference between the free store and the heap has become purely conceptual. Like a jar for collecting bugs, and one for collecting cookies. One is labeled one way, the other another. This designation is meant to drive home the point that you NEVER mix "new" and "delete" with "malloc", "realloc", or "free" (or bit level sets for that matter).

During interviews it's good to say that "new and delete use the free store, malloc and free use the heap; new and delete call the constructor and destructor, respectively, however malloc and free do not." Yet, you will often hear that the memory segments are really in the same area - however, that CAN be compiler specific, that is to say, it is possible that both can designate different memory spaces as pools (not sure why it would be, though).