What is copy-on-write?

Copy-on-write is when you share something until you need to change it, just like sharing a toy.

Imagine you and your friend both want to play with the same toy. Instead of each having their own copy, you both use the same one. But if one of you wants to paint it purple while the other wants to keep it red, that’s when things get interesting. You only make a new copy of the toy when someone changes it, that’s copy-on-write!

How It Works in Real Life

Think of your lunchbox. If both you and your friend have the same lunchbox with the same snacks, you can share it. But if you want to add an apple while your friend wants to take out a cookie, then only one of you needs to make a new copy, the other can still use the original.

Why It’s Useful

This way, you don’t waste time or space making extra copies until they’re really needed. It’s like sharing toys at first, and only getting your own when you need to change things up! Copy-on-write is when you share something until you need to change it, just like sharing a toy.

Imagine you and your friend both want to play with the same toy. Instead of each having their own copy, you both use the same one. But if one of you wants to paint it purple while the other wants to keep it red, that’s when things get interesting. You only make a new copy of the toy when someone changes it, that’s copy-on-write!

Take the quiz →

Examples

  1. Imagine you have a toy box, and instead of copying all the toys when you want one, you just mark it as yours until you need to change it.
  2. Copying your homework only happens when you start editing it, not when you first take it from your friend.
  3. A shared pizza is cut for everyone, but each person gets their own slice only when they start eating.

Ask a question

See also

Discussion

Recent activity