In the world of SSD technology, the terms Garbage Collection and TRIM are often thrown around, but what do they really mean? In this article, we’ll look at Garbage Collection, how it works, and how this relates to the TRIM command.
What is Garbage Collection?
The goal of garbage collection is to periodically optimize the drive so that it runs efficiently and maintains performance throughout its life. Unlike a hard disk drive (HDD), SSDs and other NAND flash storage cannot overwrite existing data. They have to go through a program/erase cycle. Flash memory is divided into blocks that are further divided into pages; data is written on a page level and data is erased on a block level. Before data can be erased, all the valid data (pages) from the original block must first be copied and written into the empty pages of a new block. To write to an already used block of data, an SSD controller would first copy all valid data (that which is still in use) and write it to empty pages of a different block, erase all the cells in the current block (both valid and invalid data), and then start writing new data to the newly erased block. This process is called Garbage Collection. Kingston® uses various controllers that leverage proprietary technologies to conduct Garbage Collection (GC), the purpose of which is to keep as many empty blocks as possible so that when the SSD has to write data, it isn’t waiting for a block to be erased.
The Garbage Collection process occurs automatically, usually during a system idle, and as it is a vital part of the functioning of the drive. SSDs incorporate advanced controllers that manage the NAND Flash storage. When files are deleted in an operating system such as Windows, the OS just marks its internal file table indicating that the file is deleted. On hard disk drives (HDDs), the now-invalid data remains there and can be directly overwritten by the system to store new data. Newer operating systems also support the TRIM command, whereby the OS notifies the SSD that it has deleted specific files so that the SSD can better manage the GC process to recover that space earlier and prevent saving and moving all that invalid data.