When data in a traditional mechanical Hard Disk Drive (HDD) is deleted by the operation system, invalid data will continue to exist. When new data is written, the operating system can write the data directly to the location of the deleted data. That is to say, you can overwrite old data directly to store new data. Solid-State Drives (SSDs) are very different from HDDs because SSDs use NAND Flash storage technology. When data is written, SSDs must first erase data from old chunks before the new data can be written. That is to say, new data cannot directly overwrite invalid data.
For SSDs, Garbage Collection refers to the relocation of existing data to other NAND Flash locations and the process of erasing invalid data completely. SSD data writing is conducted by page as a unit, however, data erasing is conducted by block as a unit. Therefore, to erase invalid data, SSDs need to copy valid data in chunks to a new block page, so that invalid data in the original chunks can be erased by block as a unit. When the data in the block is completely erased, a free block is formed; subsequently, it can be written with new data.
Garbage Collection means merging valid data in the original chunks into another free chunk and erasing the chunks after data is erased; the goal is to make more free blocks available to maintain SSD writing performance.