The heap is a block of memory available to our program at runtime. When we put data on the heap, we request a certain amount of memory from the allocator, which finds an empty block in the heap that is big enough and returns a pointer to it.

In C/C++, we access elements on the heap with dynamic memory allocation. In Rust, we can access it with the Box<T> unique pointer type. In many high-level languages, variables are by default on the heap.

See also

  • Heap, a data structure with the same name