heap

The area of memory where a program stores objects whose size or lifetime is not known in advance, typically reclaimed by a garbage collector.

In more detail

Value types held in local variables usually live on the stack instead. Allocating on the heap is cheap, but every object must later be reclaimed, which is why hot code avoids needless allocations. This memory area is unrelated to the heap data structure.

Examples

.NET: reference types live on the managed heap, and boxing a value type allocates there.
In Node.js the V8 heap holds every JavaScript object, string and closure; each worker thread and child process has its own.

Related terms

Taught in

References