A young man typing on his laptop keyboard in the office

The Importance of Garbage Collection and TRIM Processes for SSD Performance

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.

What is TRIM?

TRIM is a command for the ATA (Advanced Technology Attachment) interface. When the operating system needs to tell the SSD it’s deleting files and that those file pages need to be made available for new information, TRIM provides that functionality. In combination with Garbage Collection, TRIM works to clean up and organize your SSD, making it more efficient and prolonging its lifespan.

Before Windows 7 and the advent of TRIM, there was no way to designate that data stored on SSDs was cleared for removal. With TRIM, pages belonging to deleted files can be dealt with by Garbage Collection the next time the computer is idle.

Not all operating systems support TRIM. Before Windows 7, SSDs would retain invalid information until told to write new information to that location, which was both slower and detrimental to the drive’s lifespan. All subsequent Windows versions (and OS X Lion or later) automatically run TRIM for SSDs that support the feature.

How to check that TRIM is enabled on Windows

a hand typing on a laptop keyboard on a desk with a cmd command on the screen
  1. Press Windows + X keys, click "Search," and type cmd in the Search box.
  2. Right-click "Command Prompt" and choose "Run as administrator."
  3. Enter the following command: fsutil behavior query DisableDeleteNotify and hit Enter.

If the result is DisableDeleteNotify = 1, then TRIM is disabled on your SSD, but if the result is DisableDeleteNotify = 0, then TRIM is enabled on your SSD.

How to enable TRIM on Windows

  1. Right-click the Windows icon, select "Search," and type cmd in the Search box.
  2. Right-click "Command Prompt" and choose "Run as administrator."
  3. Type: fsutil behavior set DisableDeleteNotify 0 and hit Enter.

How to check that TRIM is enabled on a MacOS 10.10.4 and newer

  1. Select the Apple icon in the upper-left corner.
  2. Then click About this Mac.
  3. When the overview pops up, select System Report.
  4. Navigate to: Hardware > SATA/SATA Express.
  5. Scroll down to locate TRIM Support, the value will be Yes or No.
  6. If the value is No, proceed by opening a Terminal window.
  7. At the prompt, type: sudo trimforce enable.
  8. Hit Enter.
  9. Input your password when prompted and hit Enter.
  10. Type y at the prompt, then press Enter.
  11. Type y again and your system will reboot.
  12. Confirm TRIM is enabled by repeating steps 1-5 after reboot.

For OSX 10.10.3 and older, you can use Chameleon SSD Optimizer or Cindori Trim Enabler.

Conclusion

Your SSD will only stay at its best performance if it is properly maintained; therefore, Garbage Collection and TRIM are important processes for keeping your SSD at an optimal performance level. For Kingston drives, Garbage Collection and TRIM are automatically enabled and you can monitor the overall health of your SSD using the Kingston SSD Manager (KSM) application.

#KingstonIsWithYou

Related articles