What is a contiguous memory block?

565471741 picture 565471741 · Oct 30, 2010 · Viewed 35.7k times · Source

Just like in the title, what is a contiguous memory block?

Answer

Michael Goldshteyn picture Michael Goldshteyn · Oct 30, 2010

This is a contiguous memory block of five bytes, spanning from location 1 to location 5:

alt text

It represents bytes (colored light blue) that are together in memory with no gap bytes (white) between them.

This is a non-contiguous set of five bytes of interest:

alt text

It is fragmented into three groups of bytes (colored yellow) with gap bytes at locations 4 and 6. Starting at location 1 there is a contiguous block of three bytes, spanning from locations 1 to 3. There are two more blocks of one byte each at locations 5 and 7, respectively.

The unused block at location 0 as well as any subsequent blocks beyond location 7 can usually be ignored since they do interpose between the bytes of interest spanning from locations 1 to 7.