Buddy System Memory Allocation Technique (original) (raw)

Last Updated : 15 Apr, 2026

The Buddy Allocation System is a memory management technique that divides a large memory block into smaller power-of-two blocks called buddies.

Algorithm of Buddy System

Below are the steps involved in the Buddy System Memory Allocation Technique:

**Illustration

**Problem: A system with 128 KB memory receives a request of 18 KB.

**Solution: Nearest power of 2 ≥ 18 KB = 32 KB.We can see that if we further divide 32 in half it will be 16, which is less than 18 i.e. insufficient to store 18, therefore we can't split the memory further and 32 will become our leaf node.

Features of Buddy System

Advantages of Buddy System

Drawbacks of Buddy System

Example of Buddy System Allocation

Let total memory = 2^U and a request of size S. It will be handled as:

The system also keeps a record of all the unallocated blocks and can merge these different-sized blocks to make one big chunk.

Additional rules:

The following figure illustrates the implementation of buddy system, considering a 1024k (1-megabyte) initial block and the process requests as shown at the left of the table.

buddy_system

Flow of allocation

**Explanation of the Table:

  1. Start: One free block of 1024 KB.
  2. A = 70 KB: Split → allocate 128 KB block for A.
  3. B = 35 KB: Split → allocate 64 KB block for B.
  4. C = 80 KB: Split → allocate 128 KB block for C.
  5. A ends: Block of 128 KB freed.
  6. D = 60 KB: Allocated in a free 64 KB block.
  7. B ends: 64 KB freed → can merge with buddy.
  8. D ends: Freed → merge with buddy, coalescing larger blocks.
  9. C ends: Freed → memory fully restored to 1024 KB.

Types of Buddy System

The Buddy System is a memory allocation method where blocks are split and merged for efficient use. Different types of Buddy Systems exist to suit specific needs and optimizations in various systems.

**1. Binary buddy system

**Example: If total memory = 256KB and request = 25KB nearest power of two is 32KB.

2. Fibonacci buddy system

Zi = Z(i-1)+Z(i-2)

3. Weighted Buddy System

In a weighted peer system, each memory block is associated with a weight, which represents its size relative to other blocks. When a memory allocation request occurs, the system searches for the appropriate block considering the size of the requested memory and the weight of the available blocks.

**4. Tertiary Buddy System

In a traditional buddy system, memory is divided into blocks of fixed size, usually a power of 2, and allocated to these blocks but the tertiary buddy system introduces a third memory structure, which allows flexibility large in memory allocation.

Advantages

Drawbacks