Heap Memory

Return to Glossary

A Heap Memory, or heap, is an area of pre-reserved computer main storage (memory) that a program process can use to store data in some variable amount that won't be known until the program is running. For example, a program may a accept different amounts of input from one or more users for processing and then do the processing on all the input data at once. Having a certain amount of Heap storage already obtained from the operating system makes it easier for the process to manage storage and is generally faster than asking the operating system for storage every time it's needed. The process manages its allocated Heap by requesting a “chunk” of the Heap (called a Heap block) when needed, returning the blocks when no longer needed, and doing occasional “garbage collecting,” which makes blocks available that are no longer being used and also reorganizes the available space in the Heap so that it isn't being wasted in small unused pieces.

The term is apparently inspired by another term, Stack. A Stack is similar to a Heap except that the blocks are taken out of storage in a certain order and returned the same way. Source: https://whatis.techtarget.com/definition/heap