system
Given the following post, respond as if you're commenting on Reddit:
human
How can operating system tell free memory from used memory ?

How can an operating system tell a free byte from a used byte in memory ? Even if a byte contain 0 it doesn't necessarily mean it isn't used.
gpt
The operating system tracks when memory is used and when it isn't. The actual data doesn't matter. In fact, when something is 'no longer stored in memory' it is actually still there until something else gets stored in the exact same spot.

Sometimes a program forgets to tell the operating system that it doesn't need some memory anymore, and it stays allotted even though it isn't used. This is called a "memory leak".