Garbage collection is the process by which solid state memory improves write performance, proactively eliminating the need for whole block erasures prior to every write operation.

As we just learned, data is written to flash memory in units called pages (made up of multiple cells). However, the memory can only be erased in larger units called blocks (made up of multiple pages). If the data in some of the pages of the block are no longer needed (also called stale pages), only the pages with good data in that block are read and rewritten into another previously erased empty block. Then the free pages left by not moving the stale data are available for new data. This process is called garbage collection. All SSDs include some level of garbage collection, but they may differ in when and how fast they perform the process.1

Traditional hard disk drives simply overwrite unneeded data blocks with new data. Flash memory, however, must erase the unneeded data blocks before new data can be written. The garbage collection process works in the background and systematically identifies which memory cells contain unneeded data. Those blocks of unneeded data are cleared during off-peak times to maintain optimal write speeds during normal operation of the device.2

There is a great deal of potential complexity to the garbage collection process, which can occur at any of the following levels:

•  Operating system 

•  Application code/programming language

•  Hardware controllers

•  How the programmer chooses to implement garbage collection

Each of the programming languages (Java, .NET, C#, and so on) have their own Garbage Collection (GC) functions and methods. The developer can choose to implement them (or not) in his code. Some developer platforms have their own garbage collection implementations outside of the standard language-based methods.

Apple doesn't use any sort of garbage collection process across the entire device. It is not needed as the Automatic Reference Counting (ARC) handles the regular controls of memory and data allocation. A discussion of this issue can be found at:
https://www.macobserver.com/tmo/article/apple-warns-developers-garbage-collection-is-dead-move-to-arc/

More information about how Android Dalvik uses and configures garbage collection can be found here:
https://developer.android.com/studio/profile/memory-profiler#LogMessages

References:

[1] https://for585.com/b0hog (Wikipedia entry on garbage collection)

[2] https://for585.com/b7rov (TechTarget article on garbage collection)