⚙️Heap Memory
Also known as The Heap, Dynamic Memory, Free Store
A big part of memory. Its data can last longer than one function.
Think of it like
Think of it like a big storage room. You can put boxes anywhere, but someone must clear them out.
Example
Jack's app loads 10,000 user records into a list. The list is too big and lives too long for the stack, so it goes on the heap.
Why it matters
Almost every object, list and string in a real app lives on the heap. It is where most memory problems happen.
Definition
Common mistake
Key takeaways
- 1Lives longer. Outlasts the function.
- 2Any size. Grows as needed.
- 3Must be freed. By you or the collector.