Korva
Tech

Computer Memory Is a Neighborhood Where Every Byte Has an Address

A variable is a friendly name for data, a pointer is the street address, and the stack and heap decide between short visits and long stays.

AI image
Fireship · 100+ Computer Science Concepts Explained

Think of your computer's short-term memory as a neighborhood. That memory is called random access memory, or RAM, and inside every house lives a single byte of data. Every house has its own street address, called a memory address, which the processor can read from or write to.

When you write a program, you rarely think in bytes. You create a variable, which gives a human-friendly name to a piece of data, like a number or a word. Behind the scenes, the value of that variable is stored in one of those houses in RAM.

Sometimes a program needs to know not just what is in the house, but where the house is. That is what a pointer does. A pointer is simply a variable that stores the location of another variable, its address in memory. It is a slip of paper that says the good stuff lives at Number 42, and it gives programmers precise, low-level control over the neighborhood.

Where a variable lives depends on how long it is needed. When a program calls a function, a small job the computer is asked to do, that job is placed on what programmers call the call stack. The call stack is short-term lodging for work in progress. Each new call adds another tray to the pile, called a frame, and when the job is done, the tray comes off. If a function keeps calling itself without stopping, the trays pile up until the computer runs out of room and quits with a stack overflow error.

Data that needs to stick around cannot live in that temporary pile. It goes to a separate part of town called the heap. Unlike the call stack, the heap can grow and shrink as the program runs. It also lets multiple variables share the same object by reference, which means they all point to one shared spot instead of making expensive copies.

The lesson is that memory management is mostly deciding who stays where, and for how long. Many modern languages hire a helper called a garbage collector, which automatically reclaims space once nothing in the program still points to an item, so the programmer does not have to demolish the houses by hand.

Questions people ask

How is RAM different from storage like a hard drive?

RAM forgets everything when the power goes off, so it is only for work happening right now. Long-term storage like a solid-state drive or hard drive keeps data without power, but it is slower to reach. That is why computers load programs from storage into RAM to run them.

Can a computer run out of memory?

Yes, and running out of that temporary space is common. Every open tab, app, and background process claims houses in the neighborhood. When RAM fills up, the computer slows down as it shuffles data to slower storage to make room.

Do programmers always have to clean up memory themselves?

In languages like C, you do, and forgetting to free memory creates a leak that can crash programs. In languages like Python, a garbage collector watches for objects no one points to anymore and reclaims them automatically. It is convenient, but it adds some overhead the programmer cannot directly control.