⚙️Garbage Collection
Also known as GC, Garbage Collector, Automatic Memory Management
The language finds memory no one uses now. Then it frees it.
Think of it like
Think of it like a cleaner going room to room. They throw out what nobody uses.
Example
Lucy's JavaScript function builds a big list, uses it and returns. Nothing points at the list now. The garbage collector frees it a moment later.
Why it matters
It gets rid of a whole kind of bug, like freeing the same memory twice. So most big languages have it.
Definition
Common mistake
Key takeaways
- 1Finds unreachable data. Nothing points at it.
- 2Frees it for you. No free call needed.
- 3Costs some time. Work and short pauses.