Definition
When you keep recharging a battery before it's fully drained, it can start acting as if it "remembers" that habit, and its maximum capacity seems to shrink. It was a well-known chemical side effect of the nickel-based rechargeable batteries that used to be common.
It's like the bottom of a drink glass hardening
Imagine a glass with half a drink left in it. You never wash it. You just keep pouring new drinks on top. The leftover at the bottom slowly hardens and builds up a crust. Eventually, even when the glass is "empty," you can only fill the top half.
The same thing happened inside the nickel-cadmium (Ni-Cd) rechargeable batteries that were widely used in the past. If you plugged in the charger every time 50% or 70% was left, instead of using up all 100%, the unused chemicals developed abnormally large crystals.
Bigger crystals mean less surface area for chemical reactions, so the battery couldn't deliver power smoothly. It was as if the battery had decided, "This is my bottom," and remembered it. Its working range got narrower.
The result was frustrating. You'd charge a battery to a full 100%, but the device would shut off after using only the part you normally used.
To be more precise: the energy didn't disappear
When the memory effect set in, the electrical energy inside the battery didn't float off into the air or vanish for good.
Once the chemical crystals grew coarse, the battery's internal resistance shot up. A battery with high resistance sees its voltage drop far earlier than normal when it delivers current. Electronic devices need a steady voltage to run reliably. The moment the voltage falls below the threshold, the device decides the battery is dead and shuts itself off.
So energy was still sitting in the battery. But the voltage was too low for the device to use it.
Luckily, with nickel batteries you could often restore the original performance. You fully drained the battery, then fully charged it, and repeated that a few times. That broke up the hardened crystals.
Why you shouldn't run your phone all the way down
The smartphones, wireless earbuds, laptops, and electric cars we use every day almost all contain lithium-ion (Li-ion) batteries. Lithium-ion batteries store and release energy in a completely different way from nickel batteries, so the memory effect is practically a non-issue. In 2013, a very small memory effect was found in some lithium batteries, but it was only a few thousandths of the voltage.
In fact, lithium-ion batteries tend to wear out faster if you often drain them close to 0%. Even when your screen says 0%, the protection circuit keeps a little reserve. But if you leave the battery in that state for a long time and the voltage really does sink to the bottom, the electrodes can be damaged in ways that are hard to undo.
To keep your phone battery healthy for years, do the opposite of the old method. Don't wait for 0%. When 20 to 30% is left, top it up whenever you get the chance. That habit is the best way to protect battery life.
Just staying in the 20% to 80% range most of the time can keep your battery in good shape for much longer.
Common misconceptions
To make a phone battery last longer, you should run it down to 0% before charging.
The lithium-ion batteries in smartphones have no memory effect. In fact, draining them close to 0% often, or leaving them empty for a long time, can damage the electrodes and shorten their life.
Where you meet it
An old cordless phone or camcorder battery that you kept charging after only a little use, until its run time dropped sharply.
An old power-tool battery that you plugged into a dedicated discharger to drain it completely, then recharged to bring it back to life.
In one sentence
It happens when you recharge before using a battery up and the battery mistakes that point for its bottom. It mostly affected older nickel-based batteries and is practically a non-issue for modern lithium batteries.