It does save battery to not have a 500MB cached video pre-loaded in the background. You're being unrealistic. You want a computer, not a phone. It's clear you have no idea how iOS works.
That depends. If you
already have the data in RAM, you should keep it until something else comes along and needs it instead. Say, I leave YouTube, and go to another app that decides it needs a ton of RAM to cache something else. If the data is there, you shouldn't just immediately throw it away.
That said, iOS' approach to clearing caches is a bit brute force at times:
- App allocates RAM.
- If there isn't enough RAM available for predicted
future allocations, tell other active apps to "clear up memory".
- If there still isn't enough RAM available, start picking apps that are still running, and tell them to save state and exit. The order
should start with the least recently used app, but it is possible this algorithm is not written that way.
The "clear up memory" bit is hazy, because it is up to the individual app to decide how aggressive it should be. But if you aren't aggressive enough, iOS can simply kill your app in the background after telling you to clear up memory a couple times. Oops. And so an app like YouTube probably just throws out any pre-cached video data that it already had when asked to clear memory.
This also works on predictions, since clearing up caches and letting apps save state before they exit is somewhat expensive (100s of milliseconds, potentially), and you don't want to have to wait for your app to try to allocate 5MB with 4MB free before you go do it. Also, heap fragmentation is a problem too. You can waste a fair bit of RAM with it, and trigger these low memory cleanups faster than if you can avoid too much fragmentation of your app's memory space.