Memory allocation Techniques (Fixed and variable)

Fixed and variable partitioning determine whether the operating system divides RAM into permanent, unchangeable slots or dynamic, flexible spaces for running student programs.

10 min read · 10 cards · 3 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

The LabOne Classroom Crisis

Imagine you log into the LabOne server to run a 15 MB Python data analysis script. At the same time, your classmate wants to run a tiny 2 MB SQL query. If the LabOne operating system divides its physical RAM into strict, unchangeable 20 MB slots before anyone logs in, your script fits perfectly, but your classmate wastefully occupies a whole 20 MB slot for just 2 MB of code. How can the OS hand out desk space in RAM without wasting precious megabytes?

Theory

The Parking Lot vs The Open Playground

Think of fixed partitioning like a standard college parking lot where every slot is painted to fit a large SUV. Even if a student parks a tiny bicycle there, that slot is fully taken and cannot hold anything else. Variable partitioning is like an open grassy playground where students pitch tents of exactly the size they need. No space is wasted inside a tent, but as people pack up and leave, the remaining gaps might become too awkward for new tents to fit.

Theory

Fixed vs Variable Partitioning

In contiguous memory management, fixed partitioning divides RAM into static, unchangeable regions during system startup. Each region holds exactly one process. In contrast, variable partitioning does not pre-divide RAM. Instead, the operating system allocates memory dynamically from a contiguous block of free space, called a hole, matching the exact size requested by a process as it loads into the LabOne server.

At a glance

Key structural trade-offs between static and dynamic allocation techniques.

FeatureFixed PartitioningVariable Partitioning
Partition SizePermanent and predefinedDynamic and changes on the fly
Process LimitEqual to number of partitionsLimited only by total RAM size
FragmentationSuffers from internal fragmentationSuffers from external fragmentation
OS OverheadVery low and simple to trackHigher because it tracks free holes

Think first

Tracking a Fixed Partition Waste

Suppose LabOne has a RAM region divided into 3 fixed slots of 10 MB, 20 MB, and 30 MB. Three student programs arrive in order: P1 (8 MB), P2 (12 MB), and P3 (25 MB). Work out which partition each process occupies and calculate the total wasted space inside the slots before revealing the solution.

Show the answer

Step 1: P1 (8 MB) fits into the 10 MB slot. Wasted space inside this slot is 10 minus 8 which equals 2 MB.

Step 2: P2 (12 MB) cannot fit in the remaining 10 MB slot, so it takes the 20 MB slot. Wasted space inside is 20 minus 12 which equals 8 MB.

Step 3: P3 (25 MB) takes the 30 MB slot. Wasted space inside is 30 minus 25 which equals 5 MB.

Step 4: Total wasted space inside the partitions is 2 plus 8 plus 5 which equals 15 MB. This inside-the-slot waste is called internal fragmentation.

Quiz

If a 4 MB process is loaded into a 16 MB fixed partition on the LabOne server, what happens to the remaining 12 MB inside that partition?

  1. The OS automatically assigns it to another 12 MB process
  2. It remains completely locked and unusable by any other process
  3. The partition shrinks dynamically to 4 MB to save memory
  4. It converts immediately into secondary backing store space
Show the answer

It remains completely locked and unusable by any other process

In fixed partitioning, a slot can hold only one process at a time. Even if the process uses a small fraction of the slot, the rest of that slot is completely locked and wasted. It cannot shrink or accept a second process. This creates internal fragmentation.

Watch out

The Fragmentation Interchange Trap

A guaranteed way to lose marks in university exams is confusing where internal and external fragmentation occur. Remember this strict rule: fixed partitioning leads to internal fragmentation because space is wasted inside a predefined box. Variable partitioning leads to external fragmentation because random tiny holes develop outside allocated blocks as old programs finish and exit LabOne's RAM.

Think first

The Dynamic Growth Problem

Suppose a student program running in a variable partition suddenly needs 5 MB of extra RAM to load a new data array. If there is no free space immediately adjacent to its current block, can a contiguous variable partition simply grow in place? Think about the rule of contiguous allocation before revealing.

Show the answer

No, it cannot grow in place. Because variable allocation requires a process to occupy one single continuous block of RAM, if the adjacent space is already taken by another student's program, the OS must either find a completely new large hole, move the entire process there, or crash the program with an out of memory error.

Theory

Real World Memory and Unit 4

While modern operating systems use advanced paging techniques, understanding these basic partition mechanics is vital. You will see a variation of fixed layout when we partition hard drives during our Linux installation lab in Unit 4. There, you will divide a single disk into explicit, unchanging partitions like root and swap before booting the system.

Summary

Key takeaways

  • Fixed partitioning sets unchanging memory boundaries at startup, limiting the number of active tasks.
  • Variable partitioning creates slots dynamically based on the exact size each process requests.
  • Fixed partitioning suffers from internal fragmentation due to leftover room inside slots.
  • Variable partitioning suffers from external fragmentation due to scattered holes between slots.
  • Contiguous allocation means every process must reside in a single unbroken block of RAM.
  • Memory hook: Fixed partitions waste space inside: variable holes leave gaps outside!

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from File and Memory Management

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Memory allocation Techniques (Fixed and variable) · Operating System · Gri-Learn