Garbage collection
- Sprouting
- c.
“Garbage collection” is an automatic memory management strategy. Typically, a runtime component will periodically check for unreachable memory, either at specific intervals, or when memory is full.
GC traces a graph of reachable memory by traversing each accessible object pointer from the root (memory stack). Any objects stored on the “heap” that cannot be reached are marked for removal and destroyed in a batch operation, deallocating the memory.
Because GC pauses execution during tracing, real-time performance can be impacted. Unlike ARC, heap memory remains allocated unitl the next mark-and-sweep cycle.