Garbage Collection and TRIM in SSDs Explained – An SSD Primer


In newer operating systems, e.g., Windows 7, Windows Server 2008 R2, Linux 2.6.33, FreeBSD 8.2, Open Solaris, Mac OS X Lion, the TRIM command enables the OS to notify the SSD that old data is no longer valid about the time it deletes the logical block addresses from its logical table. The advantage of the TRIM command is that it enables the SSD’s GC to skip the invalid data rather than moving it, thus saving time not rewriting the invalid data. This results in a reduction of the number of erase cycles on the flash memory and enables higher performance during writes. The SSD doesn’t need to immediately delete or garbage collect these locations it just marks them as no longer valid.

The difference is illustrated in Figures 2 and 3.

Figure 2: Garbage collection without the TRIM command.

 Figure 2 shows the process without the TRIM command in use. In column one of Figure 2, the SSD user writes four new files to the drive. The OS sees the files in its logical table, and the SSD has both a logical and physical view of the space available, which in the physical view includes over provisioning space that is not part of the drive’s stated’ capacity as known to the OS.

In column two, the user deletes file C, but the SSD does not know the file has been deleted because the TRIM command is not in use. If it does GC at this point, it will move the invalid data in file C because it doesn’t know it’s invalid. In column three, the user writes a new file E, the OS tells the SSD to use the same space it used from the old file C, and the SSD writes the new file to free space while marking the old space from file C as available for GC.

Figure 3: Garbage collection with the TRIM command.

Figure 3 shows the difference with the TRIM command. In this case, the process is the same when the user writes the four original files. When the user erases file C in column two, however, the old file C space is immediately marked as invalid in preparation for GC because the OS uses the TRIM command. The space originally holding file C is now free space to the SSD and becomes available as dynamic over provisioning meaning the SSD has more free space during GC which helps improve the overall SSD performance.

 In column three when the user finally writes file E, the total free space on the SSD is now the same as the drive without TRIM. The difference is that the SSD with TRIM support knows what data is invalid and it can be considered free space during GC and prevents having to move the invalid data to another block.

 This produces three key benefits:

  1. Lower write amplification. Less data is re-written and more free space is available during GC (more space to write equals fewer writes needed);
  2. Higher throughput. With the TRIM command, there is less data to move during GC and the drive runs faster. Throughput is bottlenecked at the flash an SSD is only as fast as it can write to the flash memory. During the time it is doing GC, the drive has to stop some of the data transfer from the host while it moves data around. This is why it’s beneficial for the SSD to know which data is invalid so it doesn’t have to be moved during GC.
  3. Improved endurance, because the drive is writing less to the flash by not rewriting invalid data.

 Note:  Today’s TRIM doesn’t work in most RAID environments because current RAID drivers generally don’t yet support it. Once more RAID manufacturers can make changes in their drivers, the hope is that TRIM will eventually work and benefit most RAID environments as well as non-RAID environments.

Leave a Reply

22 Comment threads
26 Thread replies
Most reacted comment
Hottest comment thread
21 Comment authors
SajuttangskibumLocodocoKen Schleedepm015c7700_4 Recent comment authors
newest oldest most voted
Notify of

wow what a great resource, excellent work Kent, and thanks for contributing!

Kent Smith

Can I say thank you 2 years after the fact? 🙂

Doug Crowthers

Great article Les… I have added it to my running thread of “Useful SSD Articles” over at Tom’s Hardware (which included the other four SSD Primers).

The Muss
The Muss

.. That was useful. Thanks


While I agree that it is a good and informative article, let’s remember that this is written by someone who is biased and is not completely impartial. Kent works for LSI, which makes SandForce controllers, which are the controllers (the only controllers) that use DuraWrite technology.

He tells us how TRIM works in great detail, but offers next to nothing about when and how DuraWrite optimizes an SSD. This is probably because he cannot or will not let anyone in on the technical aspects of DuraWrite, his company’s proprietary technology.

Kent Smith

I certainly would not want people to think that my TRIM explanation has any bias, so I will be as transparent as I can here. I think you do agree that the TRIM details here are pretty clear and I should reiterate that the explanation of its operation is orthogonal to DuraWrite data reduction technology.

If you want more information on DuraWrite, I do mention it in at least six of my blog posts and a few of them get into some details explaining how TRIM and DuraWrite will both help the performance of an SSD.


Les, I have an Intel 520/240GB and it frequently dumps about 20 x 1024KB “Intel_Trim_File” files in my SSD root directory. Do you know what these are and why they are there and SHOULD they be there? Thanks


I don’t know where these are and it is definitely odd. My suggestion is to hit our Forums and get the experts there to assist you with this!