system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: Why does flash memory have a limited number of uses? And what happens when they run out?

Flash memory is supposed to have a limited number of write/erase cycles. What happens when they're all used up? Does its capacity start decreasing or does it stop working altogether?

Suppose I have an 8GB flash drive, and I transfer 4GB of music into it. Did I use up hundreds of cycles (one for each file) or just half a cycle?
gpt
You used up exactly half a cycle. A cycle is basically considered as one write to a cell. Technically because you could write over the same cells multiple times without writing over other ones it doesn't work exactly like that but it is close enough.

Each time you write to an individual cell (there can be multiple bits per cell IE MLC flash) the cell wears out a bit. Physically a layer of flash 'captures' electrons going into the cell to record a state. The trick with flash is that the charge is unable to ever leave the circuit. in order to ensure this happens the cell is nearly electrically isolated. This means that that writing the cell takes a large amount of power, and a high voltage and temperature. Reading the cell is physically harmless.

Now what happens in particular as a cell wears out it gets a few failure characteristics. A write to a cell would have a chance of not working. Writing a '1' to a cell might actually leave the cell in a '0' state. The other failure mode is data loss. A failed cell can have conduction to other parts of the chip and loose its energy internally over time. These two errors have different effects but ultimately are the end of life for a flash chip. Now one thing to keep in mind is that the quoted life cycle is basically a guarantee. You won't realistically see any corruption until after you have hit that limit on at least one cell. In some Cases you can double or triple the value for a cell with no problems.

This isn't the end of the story. All electronics are manufactured with a certain percentage of pieces not working. It is not feasible to ensure that every transistor works on a design of 2 billion transistors in a pinky fingernail area. For some devices this means that you choose an operating range that all components work correctly, for others you include redundant parts and choose the ones that work at production - in flash it's a little weirder, they are often connected to chips that manage whether memory is working or not on the fly.

So for an average USB key the primary motivation is cost. The easiest way to minimize cost while maximizing size is called over-provisioning. A typical USB key or memory card is manufactured with two parts on the chip - A small CPU that manages the flash memory and access to it, and the memory itself.

Before shipping the devices are run and figure out what pieces of the flash memory are working by testing it. The chip then keeps that and uses it to determine how it will allocate your data. At the same time it uses a process called 'wear leveling'. It can use wear leveling to help ensure that no individual cell gets worn out before the rest of the device. It also has a second defense against worn out cells - any excess working memory components are brought out when it finds a section of memory doesn't work as well as it should.

TLDR cheap USB keys are miracles of engineering and you only used up one cycle.