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.
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.
Apply Spatie's Laravel and PHP coding standards for any task that creates, edits, reviews, refactors, or formats Laravel/PHP code or Blade templates; use for controllers, Eloquent models, routes, config, validation, migrations, tests, and related files to align with Laravel conventions and PSR-12.
Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or when debugging dependency cycles between application layers.