高效的 C 池分配器?

发布于 2024-10-04 02:57:40 字数 213 浏览 1 评论 0原文

我目前正在尝试用 C 语言编写 2D 场景图,并且需要决定存储子节点的方式。我期望有很多读取和很少写入,因此由于引用的空间局部性较差,因此链表是不可能的,并且每次添加子节点时使用 realloc 可能会导致空闲碎片列入遗忘名单。池分配器似乎是最好的解决方案,但我似乎找不到任何可以使用的实现。有谁知道一个分配器可以有效地处理数百个小型结构的随机分配和取消分配,或者可能是更好的分配方案?

I'm currently attempting to write a 2D scene graph in C, and I need to decide on a way of storing the child nodes. I'm expecting very many reads and few writes, so a linked list is out of the question due to poor spatial locality of reference, and using realloc every time to add a child node would probably fragment the free list into oblivion. A pool allocator seems to be the best solution, but I can't seem to find any implementations to use. Does anyone know of an allocator that would efficiently handle random-ish allocations and deallocations of a few hundred small structs, or perhaps a better allocation scheme?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

椵侞 2024-10-11 02:57:40

我正准备将 TLSF 部署为实时分配器。我还没有机会分析它的性能,但它似乎有效,并且 许可证是正确的。

根据他们的文档,其操作“在 x86 架构中最多执行 168 条处理器指令”。它以单个 .c 文件形式出现,在我的系统上无需修改即可编译。

I'm preparing to deploy TLSF as a real-time allocator. I haven't had a chance to profile its performance yet, but it seems to work, and the license is right.

According to their docs, its operations execute "a maximum of 168 processor instructions in a x86 architecture". It comes as a single .c file, which compiled without modifications on my system.

柠北森屋 2024-10-11 02:57:40

看看halloc,它可能会有所帮助。

http://swapped.cc/halloc/

Take a look at halloc, it might be of some help.

http://swapped.cc/halloc/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文