Why SSDs need it

NAND flash reads and programs in pages of around 16 KB but can erase only whole blocks of hundreds to thousands of pages, several to tens of megabytes, because erasure applies high voltage to an entire well. A page cannot be overwritten in place. When the host updates data, the SSD controller writes the new version to a free page, updates its logical-to-physical map in the flash translation layer (FTL), and marks the old page invalid. Over time blocks fill with a mix of valid and invalid pages, and free blocks run out unless space is reclaimed.

How a collection pass works

The controller selects victim blocks, typically those with the most invalid pages because they need the least copying. It copies the remaining valid pages to another block, updates the mapping, erases the victim and returns it to the free pool. Ideally this runs in the background during idle time; if free blocks are exhausted it must run in the foreground, stalling host writes. The fuller the drive, the fewer invalid pages each victim holds, so more copying is needed per block reclaimed and write performance drops.

Write amplification

Every valid page moved during collection is an extra write the host never asked for. The write amplification factor (WAF) is the ratio of data written to flash to data written by the host, and under small random writes it can reach several times. Because each NAND block tolerates only a limited number of program/erase cycles, a high WAF shortens drive life as well as consuming bandwidth. Garbage collection is distinct from wear leveling, which spreads erase cycles evenly across blocks, though controllers coordinate the two.

Making collection cheaper

Three levers reduce the burden. TRIM, or Deallocate in NVMe, lets the operating system report deleted ranges, so the drive can treat those pages as invalid instead of copying them. Over-provisioning installs more flash than the user-visible capacity; 512 GiB of NAND sold as a 480 GB drive leaves about 14% spare, giving collection room to work, and enterprise drives reserve more. Data compression in some controllers reduces the volume written. Together they lower WAF, stabilize write speed and extend endurance.

Try it: questions about Garbage collection

Which correctly describes garbage collection in an SSD?

  1. AMoving valid data out of blocks that contain invalid data, then erasing those blocks to create free space
  2. BRemoving computer viruses
  3. CCompressing data
Show answer and explanation

Answer: A. Moving valid data out of blocks that contain invalid data, then erasing those blocks to create free space

NAND cannot overwrite in place and erases only by block, so each rewrite leaves the old version behind as an invalid page. The controller picks blocks with many invalid pages, moves their valid data to another block, and erases them to create free space. These extra copies cause write amplification, and the fuller the drive, the more often garbage collection runs and the more write performance suffers.

Which command notifies an SSD of space freed by files deleted by the OS, making garbage collection more efficient?

  1. AECC
  2. BISPP
  3. CTRIM
Show answer and explanation

Answer: C. TRIM

Deleting a file only updates the OS's bookkeeping, so the SSD does not know the data is obsolete and keeps copying it during garbage collection. The TRIM command tells the SSD which ranges are no longer needed; it marks those pages invalid and can erase them without copying, reducing write amplification and improving performance and lifespan. NVMe provides the same function through the Deallocate attribute of the Dataset Management command.

FAQ

What is the difference between TRIM and garbage collection?

TRIM is a command from the operating system telling the SSD which logical blocks are no longer in use. Garbage collection is the drive's internal process of copying valid data and erasing blocks; TRIM makes it cheaper by marking deleted data invalid so it is not copied.

Why does an SSD slow down when it is nearly full?

With little free space, victim blocks still hold many valid pages, so garbage collection must copy more data per erased block and often runs in the foreground, increasing write amplification and stalling host writes.

Is SSD garbage collection the same as garbage collection in programming languages?

Only by analogy. Language runtimes reclaim unreachable memory objects, while an SSD reclaims flash blocks by relocating valid pages and erasing the rest, a requirement imposed by NAND's block-level erase.

Questions that mention Garbage collection (4)

Garbage collection appears in 6 practice questions across 1 topic, including SRAM and flash memory.

  1. What is the unit in which data is erased in NAND flash memory?
  2. Which correctly describes "overprovisioning" in an SSD?
  3. Which correctly describes "write amplification" in an SSD?
  4. What is the basic unit for reading and writing (programming) in NAND flash memory?

Books on SRAM and flash memory Ad

As an Amazon Associate I earn from qualifying purchases.

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary