SSD Simulator
The FTL at Work

Garbage Collection: Cleaning Up Stale Data

How the SSD reclaims space — and why it can never be free.

Every overwrite leaves a stale (invalid) page behind. Eventually the SSD runs low on erased pages to write into. Garbage collection (GC) is the process that reclaims that wasted space — but because erase works on whole blocks, GC must first rescue any still-valid pages.

The GC cycle

  1. Pick a victim block — usually the one with the fewest valid pages (most garbage to reclaim).
  2. Migrate the victim's still-valid pages by copying them to a fresh block.
  3. Erase the victim block, returning it to the pool of free, writable blocks.
Greedy GC: reclaim the block with the least valid data Victim 1 valid,4 invalid → migrate valid Fresh block → erase victim free again
GC copies the one valid page out, then erases the block. That extra copy is the cost of cleaning.
GC is not free: rescuing valid pages means extra physical writes that the host never asked for. The more valid data a victim holds, the more copying — and the higher the write amplification.

Victim-selection policies

  • Greedy — always pick the block with the fewest valid pages. Simple and usually excellent.
  • Cost–benefit — also favor blocks whose data is "cold" (hasn't changed in a while), so you don't keep re-collecting hot data.
  • FIFO — reclaim the oldest block. Cheap to track, but ignores how much garbage a block holds.
Analogy. GC is like defragmenting a parking garage that can only demolish and rebuild an entire floor at a time. Before you demolish a floor, you must drive out every car still in use — and every one of those drives is wasted effort you'd rather avoid.

When does GC run?

GC kicks in when free space falls below a threshold (a watermark). If the drive is nearly full of valid data, victims hold lots of valid pages, copying explodes, and both performance and endurance suffer. This is why SSDs reserve hidden spare capacity — over-provisioning.

In the EyanaSSDSim paper & simulator. EyanaSSDSim supports greedy, cost–benefit, and FIFO policies and reports the resulting write amplification for each. On the Live Simulator you literally watch victim blocks lose their valid pages, get erased (snap to white/free), and rejoin the pool.