DEV Community

Discussion on: Explain a "memory leak" like I'm five

Collapse
 
mellen profile image
Matt Ellen

OK. So you know how you like to watch Peppa Pig on Netflix? And you know when we go shopping I have to pay for the things we buy?

Well, I also have to pay for Netflix.

Unlike with the shopping, I have set something up that sends money to Netflix every month.

If I cancel Netflix, so that you can't watch Peppa Pig anymore, I would also have to stop automatically sending money every month to Netflix. If I forget to do that then I will start losing money, like how water leaks out of a hole in a bucket.

On a computer or phone or tablet, apps have to give a certain amount of memory for each thing you can see on the screen, and each part of each thing. When a thing goes away, like when you close your Peppa Pig game, then the app has to give the memory back so that other apps can use it, like how I have to stop paying for Netflix if we no longer want to use it. If the app doesn't give the memory back then eventually the computer will run out of memory and no apps can run, like if I forgot to stop paying for things we would run out of money and not be able to buy anything else.