DEV Community

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

Collapse
 
siddharthshyniben profile image
Siddharth

Imagine the computer is a hotel, and programs are people coming to the hotel, and the rooms are memory. So, programs rent rooms (memory) and use them. Later, they can leave the room (memory) so that others can use the room (memory).

A memory leak happens when an person (program) leaves the room without telling anyone. Now, that room (memory) is locked there, and others cannot use it because the hotel thinks that someone else is using it. This is a memory leak.

Collapse
 
siddharthshyniben profile image
Siddharth

Some OSs are smarter than others, and figures out that memory is not used and clears the memory and kicks out your program anyways. But some OSs like Windows, just keep asking 'do you want this memory anymore?'.