buddy memory allocation相关整理
概述 wiki上的定义: The buddy memory allocation technique is a memory allocation algorithm that divides memory into partitions to try to satisfy a memory request as suitably as possible. This system makes use of splitting memory into halves to try to give a best fit. 伙伴内存分配技术是一种内存分配算法,它将内存划分为多个分区,以尝试尽可能适当地满足内存请求。 该系统利用将内存分成两半来尝试提供最佳匹配。 算法 伙伴系统有多种形式; 将每个块细分为两个较小块的块是最简单,最常见的一种。 选定块的大小要根据实际情况选取,太小则需要更多的内存记录跟踪内存分配, 太大又容易产生空间浪费,另外,就是如果选择2的次幂单位的话, 最大的块有可能不会覆盖整个内存. 例子 同样是wiki的例子,申请的内存调整了下 Step 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 64K 1 24 2.1 23 23 2.2 22 22 23 2.3 21 21 22 23 2.4 20 20 21 22 23 2.5 A:20 20 21 22 23 3 A:20 20 B: 21 22 23 4 A:20 C:20 B: 21 22 23 5.1 A:20 C:20 B: 21 21 21 23 5.2 A:20 C:20 B: 21 D: 21 21 23 6 A:20 C:20 21 D: 21 21 23 7.1 A:20 C:20 21 21 21 23 7.2 A:20 C:20 21 22 23 8 20 C:20 21 22 23 9.1 20 20 21 22 23 9.2 21 21 22 23 9.3 22 22 23 9.4 23 23 9.5 24 初始化状态,每块64K, 最大的块包含 24 个块, 一个4阶块. ...