Flash-based storage devices are different in the way they deal with previously deleted data compared to traditional disks. Data must be erased first before new data can be written to the same block in SSDs. Garbage Collection copies in-use data to a new block, and then deletes all data from the old one.
Why Garbage Collection?
Flash-based storage devices are different from traditional hard disk drives where new data typically over-write old data in place at the same physical location. In SSDs, new data are written to open Flash memory blocks and the corresponding old data associated with the logical addresses are invalidated. Garbage Collection consolidates new and valid data into contiguous memory locations and then deletes invalid data from physical Flash memory to free up memory blocks for new data.
How Does It Work?
A Flash cell is made up of pages, and several pages make up a block. SSDs read and write data as pages, and erase data at the block level. To write new data to a used block, an SSD controller must first copy all valid data, and write it to empty pages of a different block. It then erases both valid and invalid data in the current block before the newly erased block can be written in new data. This process is called Garbage Collection.