Here’s a worked‐out comparison for tracking a 1 GB memory region that’s currently split into alternating 3 MB and 5 MB chunks (i.e. an 8 MB “pair” repeated 128 times ⇒ 256 segments total).
-
Bitmap
• Assume we track at 4 KB granularity (a typical page‐size)
• Number of pages = 1 GB ÷ 4 KB = 2³⁰ ÷ 2¹² = 2¹⁸ = 262 144 pages
• Bitmap needs one bit per page ⇒ 262 144 bits = 32 768 bytes ≈ 32 KB
-
Linked-list of segments
• Number of segments = (1 GB ÷ 8 MB) × 2 = 128×2 = 256 nodes
• Assume each node stores:
– start address (4 B)
– length (4 B)
– status flag (1 B)
– next & prev pointers (8 B each on a 64-bit system)
– (padding & alignment to 32 B total per node)
• Total = 256 nodes × 32 B ≃ 8 192 B ≈ 8 KB
────────────────────────────────────────
Summary of overhead
• Bitmap → ~32 KB of bookkeeping
• Doubly-linked list → ~8 KB of bookkeeping
Which is “better”?
– If your sole criterion is minimum tracking memory, the linked list wins hands down.
– If you need very fast random/free‐by‐address operations or very fine-grained splits, a bitmap can be simpler to scan/manipulate (but at ≈4× the memory cost in our example).
In most real kernels you actually see a hybrid approach (bitmap for page frames, free-list for variable-sized segments), but for pure memory‐overhead the linked list is lighter. 😊