What does Trim do?
The Trim command tells the SSD that specific areas contain data that is no longer in use. From the user's perspective, this data has been deleted from a document. Because of the way solid state drives read and write information, the data is not deleted from the drive at the user's command. Instead, the area of the SSD that contains the data is marked as no longer used. The Trim command tells the drive that the data can be removed. The next time the computer is idle, Active Garbage Collection will delete the data.
If the Trim command did not exist (as was the case before Windows® 7), then the solid state drive would not know that certain sectors in the drive contained invalid information until the computer told the drive to write new information to that location. The drive would need to erase the existing information, then write the new information. This takes slightly more time to do than just writing the new information, so using Trim and Active Garbage Collection helps your SSD perform write commands more quickly.
Trim also affects the longevity of the solid state drive. If data is written and erased from the same NAND cells all the time, those cells will lose integrity. For optimum life, each cell should be utilized at roughly the same rate as other cells. This is called wear leveling. The Trim command tells the SSD which cells can be erased during idle time, which also allows the drive to organize the remaining data-filled cells and the empty cells to write to to avoid unnecessary erasing and rewriting.
How Active Garbage Collection works
Flash memory, which is what SSDs are made of, cannot overwrite existing data the way a hard disk drive can. Instead, solid state drives need to erase the now invalid data. The problem is that a larger unit of the memory, a block, must be erased before a smaller unit, a page, can be written. For example, if there are four pages with data in an otherwise empty block and three pages of data are deleted, the remaining page of data must be written to a new block, then all four pages in the old block can be deleted, freeing them up to be rewritten in the future.
If the drive were to not go through this process of moving valid information so that invalid information can be deleted, and instead, just keep writing new information to new pages, eventually it would fill up with data, some of it no longer valid. To prevent this, Active Garbage collection goes through the disk and moves each page of valid data to a page in another block so the block with invalid data, which has been identified with Trim, can be cleaned out.