Memory Fragmentation Calculator
Estimate memory fragmentation percentage from free memory chunk size distribution.
Inputs
Size of the contiguous allocation needed
Fragmentation Index
93.75%
Can Satisfy Request
false
Largest Free Chunk
256MB
Deficit for Allocation
256MB
Step by step
Fragmentation index
1 - (largest_chunk / total_free) = 1 - (256 / 4096)
= 93.75%
Can satisfy allocation?
256 MB >= 512 MB?
= No (deficit: 256 MB)
How it works
Memory fragmentation occurs when free memory is scattered in small non-contiguous chunks rather than available in large blocks. The fragmentation index (1 - largest_chunk/total_free) ranges from 0% (all free memory is one chunk) to near 100% (free memory is highly scattered). High fragmentation can cause large contiguous allocations to fail even when total free memory appears sufficient — a common issue affecting HugePages, DMA buffers, and large kernel allocations.
Formula
Fragmentation index
fragmentation% = (1 - largest_free_chunk / total_free_memory) × 100
- C_{max}
- largest contiguous free chunk
- M_{free}
- total free memory
Frequently Asked Questions
How do I check memory fragmentation on Linux?
Read /proc/buddyinfo to see the buddy allocator's free page counts at each order (4KB, 8KB, ..., 4MB). Low counts at higher orders indicate fragmentation. Also check /proc/pagetypeinfo for more detail.
How does the kernel handle fragmentation?
Linux uses memory compaction (moving pages to create contiguous free space) and reclaim (freeing cached pages) to satisfy large allocations. You can trigger compaction manually via 'echo 1 > /proc/sys/vm/compact_memory'.