Trusted answers to developer questions

Contiguous memory

Get the Learn to Code Starter Pack

Break into tech with the logic & computer science skills you’d learn in a bootcamp or university — at a fraction of the cost. Educative's hand-on curriculum is perfect for new learners hoping to launch a career.

svg viewer

Data is stored in arrays of bytes8bits = 1byte. The main memory(RAM) in computers is separated into two parts:

  • Operating system
  • User processes

A chunk of main memory is reserved for the operating system and its memory management. The rest of the main memory is utilized by the user when the user runs any processes on the device. One of the ways to allocate memory to user processes is in the form of contiguous memory.

What is contiguous memory?

Consecutive blocks of memory allocated to user processes are called contiguous memoryThe memory chunks are in-place instead of being scattered across the memory.. For example, if a user process needs some x bytes of contiguous memory, then all the x bytes will reside in one place in the memory that is defined by a range of memory addresses: 0x0000 to 0x00FF.

The contiguous memory can be partitioned in two ways:

  • Fixed sized partition
  • Variable sized partition

Fixed sized partition

The memory is partitioned into pre-determined, fixed-size memory chunks. All the user processes are allocated in one partition.

Partitioning the memory into fixed sizes allows you fast access to data in memory and smoother memory management. However, this efficiency is achieved at the cost of internal fragmentationMemory wastage inside a partition.

Variable sized partition

Instead of the memory being divided into fixed sizes, it is partitioned into consecutive, but variable-sized memory chunks for the user processes.

Although having memory partitioned helps you counter internal fragmentation, it also results in sluggish access to data in the memory and complicated memory management.

RELATED TAGS

contiguous
memory
jargon
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?