Card 09/ 09
All 9 cards
RecapDifficulty: Advanced1 min
Two Regions, One Rule, Two Errors
Five things this topic established, and where each one was.
| The thing | Where |
|---|---|
| Variables live in stack frames; every object lives on the heap | Where a Value Lives While Your Method Runs |
| An object survives while a path from a root reaches it, and no longer | What Keeps an Object Alive |
| A stack overflow is recursion; an out-of-memory is reachable objects | StackOverflowError Against OutOfMemoryError |
System.gc() requests a collection and cannot free anything reachable | Why System.gc() Is a Suggestion |
| A leak is code holding references it has no use for | A Memory Leak in a Language That Collects Memory |
The one worth carrying: reachability, not usefulness, is the whole rule. The collector has no idea what you are finished with, so anything still on a path from a static field, a live frame or a running thread stays exactly where it is.