Difference Between Spatial Locality and Temporal Locality
Prerequisite – Locality of Reference
1. Spatial Locality :
Spatial Locality means that all those instructions which are stored nearby to the recently executed instruction have high chances of execution. It refers to the use of data elements(instructions) which are relatively close in storage locations.
2. Temporal Locality :
Temporal Locality means that a instruction which is recently executed have high chances of execution again. So the instruction is kept in cache memory such that it can be fetched easily and takes no time in searching for the same instruction.
Difference between Spatial Locality and Temporal Locality :
| S.No. | Spatial Locality | Temporal Locality |
|---|---|---|
| 1. | In Spatial Locality, nearby instructions to recently executed instruction are likely to be executed soon. | In Temporal Locality, a recently executed instruction is likely to be executed again very soon. |
| 2. | It refers to the tendency of execution which involve a number of memory locations . | It refers to the tendency of execution where memory location that have been used recently have a access. |
| 3. | It is also known as locality in space. | It is also known as locality in time. |
| 4. | It only refers to data item which are closed together in memory. | It repeatedly refers to same data in short time span. |
| 5. | Each time new data comes into execution. | Each time same useful data comes into execution. |
| 6. | Example : Data elements accessed in array (where each time different (or just next) element is being accessing ). |
Example : Data elements accessed in loops (where same data elements are accessed multiple times). |
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
Recommended Posts:
- Difference between Spatial and Temporal Data Mining
- Computer Organization | Locality and Cache friendly code
- Locality of Reference and Cache Operation in Cache Memory
- Difference Between DAS and SAN
- Difference between JSP and ASP
- Difference between GCC and G++
- Difference between H.323 and SIP
- Difference between DFD and ERD
- Difference between C and C#
- Difference between LED and LCD
- Difference between RAM and ROM
- Difference between 4NF and 5NF
- Difference between USB 2.0 and USB 3.0
- Difference between Tor and VPN
- Difference between IBM DB2 and MS SQL
- Difference between LAN and MAN
- Difference between PIP and HLP
- Difference between PIP and PCP
- Difference between ADO and ADO.NET
- Difference between HLP and PCP
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

