Cache memory is a small, high-speed memory located inside or very close to the Central Processing Unit (CPU). It stores frequently used data and instructions so that the CPU can access them much more quickly than if it had to retrieve them from the main memory (RAM).
Purpose of Cache Memory
-
Reduces the time the CPU needs to access data from the main memory.
-
Improves processing speed and efficiency.
-
Minimizes latency (delay) between the CPU and memory access.
Types of Cache Memory
Cache is usually organized into levels, with each level having different speed, size, and proximity to the CPU core:
-
L1 Cache (Level 1):
-
Smallest (16–128 KB per core)
-
Fastest
-
Located inside the CPU core
-
Stores very frequently used data
-
-
L2 Cache (Level 2):
-
Larger (256 KB – 1 MB per core)
-
Slower than L1, but still fast
-
May be shared or dedicated per core
-
-
L3 Cache (Level 3):
-
Even larger (2–64 MB or more)
-
Shared among multiple cores
-
Slower than L1 and L2 but still much faster than RAM
-
How Cache Works
-
When the CPU needs data, it first checks the L1 cache.
-
If not found (cache miss), it checks the L2, then L3.
-
If still not found, it retrieves it from RAM (much slower).
-
Once fetched, the data is stored in the cache for future access.