Pizza Pantry Collector
The moon cafΓ© pantry is full! Build a tiny cleanup program that protects every ingredient still connected to an active order and reclaims everything truly unused.
π§ Before we start
Your heartbeat circuit breaker remembered which safety state it was in. Today, programs also remember objects. A garbage collector follows connections from active roots, marks everything still reachable, then sweeps unused memory clean.
Arrange the cleanup program
Tap four visual instruction blocks in the collector's safe order. It must discover what is still needed before clearing anything.
Trace every reachable item
Start at the two red root cards. Follow each βneedsβ arrow and tap every connected card. Dashed cards have no path from an active root.
Sweep only unused memory
Green cards were marked reachable. Tap the three unmarked leftovers to reclaim their pantry slots. Never sweep a live ingredient.
Debug the sticky spoon leak
A finished recipe still points to an old spoon. That stale arrow makes the collector think the spoon is reachable forever. Pick the real repair.
cannot be swept
π What you learned
- Program memory holds objects that can point to other objects.
- Roots are objects the running program is actively using.
- The mark phase follows references and protects every reachable object.
- The sweep phase reclaims only unmarked, unreachable objects.
- A stale reference can cause a memory leak by keeping unused data reachable.