DELAPARRA
Index
Color
NL
Category: Core glossary

Heap

Explained by Updated

What is Heap?

Heap: A region of memory used for dynamic allocation. Objects allocated at runtime live on the heap; they persist until explicitly freed or garbage collected. The heap is the area of memory where programs store data created while running, such as objects, arrays and strings whose size or lifetime is not known in advance.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Heap

How is Heap used in practice?

It is separate from the stack, which holds function calls and their local variables and is cleaned up automatically when a function returns. Heap data lives until it is no longer needed. In languages like PHP, Java and JavaScript, a garbage collector frees it; in C you free it yourself.

What should you keep in mind with Heap?

You notice the heap mostly when memory runs out. A PHP script that loads 200,000 database rows at once can exceed its memory limit. Processing data in chunks, with chunk() or lazy() in Laravel, or streaming instead of loading everything, keeps memory usage flat however large the data set grows.

At a glance

CategoryCore glossary
Explained by
Updated

More Core glossary terms

All terms starting with H

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.