What are memory leaks?

A memory leak happens when something takes up space it shouldn’t, and never lets go, like a toy you keep holding onto even after playing is done.

Imagine you’re at the park with your favorite ball. Every time you throw it, it goes far away, but instead of coming back to you, it just stays out there. You keep throwing more balls, each one going farther, and soon you have so many balls floating around that you can’t play anymore, they're all scattered in the park.

That’s like a memory leak in a computer. The computer has a big bag of toys (we call it memory) to help it do things faster. When it uses a toy (like a ball), it should put it back in the bag when it's done. But if it forgets, that toy stays out, and more toys get used up, until there’s no room left for new ones.

Why It Matters

If the computer can’t put things back in its bag, it gets slower and slower, just like you would if you had to chase all those balls across the park. Eventually, it might not be able to do anything at all, like when you’re too tired from chasing balls to play anymore!

Take the quiz →

Examples

  1. Imagine you're playing a video game, and every time you finish a level, you leave behind a toy, eventually, the room gets too full to play.
  2. A smartphone app keeps using more memory even after it's closed, making the phone slower over time.
  3. A computer program forgets to clean up old data, like leaving a bunch of paper clutter on your desk.

Ask a question

See also

Discussion

Recent activity