Memory Locality

Memory locality is the principle that programs tend to access data and instructions in patterns that are predictable and optimized for performance.


  1. Temporal locality occurs when a program accesses the same memory location repeatedly within a short period.
    • This type of locality takes advantage of the tendency to reuse recently accessed data or instructions.
    • Example: In a program loop, a counter variable is repeatedly updated and accessed. Since the variable resides in memory, repeated access to it demonstrates temporal locality.