推荐superjan · 2025-01
“There’s a great paper from the group of Emery Berger, where they merge memory pages that become sparse.”
推荐 Emery Berger 组的论文,合并变稀疏的内存页
无需改源码的 malloc 替代品,用随机算法消除内存碎片
Mesh 是一个可直接替换 malloc 的内存分配器,用随机化算法结合虚拟内存操作,把稀疏的内存页合并,从而在不修改 C/C++ 程序的前提下消除碎片,并以高概率突破经典的 Robson 界。它的运行性能与最先进的分配器相当,同时让 Firefox 的内存占用降低 16%,Redis 降低 39%。
HN 上的人用它说明“碎片问题在 C/C++ 里也能解决”:不改源码就能做类似垃圾回收的内存压缩,有人还考虑把它用在自己的语言运行时里。
“There’s a great paper from the group of Emery Berger, where they merge memory pages that become sparse.”
“Fragmentation is solvable. Mesh can compact C programs using malloc/free without any source changes.”
“crazy enough nobody bothered to publish it until February this year!”
“Actually...Mesh”
“We planned to use something like MESH [0] to reduce the fragmentation.”