自定义内存分配器在C /经理吗?哪种方法? [英] Custom memory allocator/manager in C ? which approach?

查看:152
本文介绍了自定义内存分配器在C /经理吗?哪种方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找用C语言编写的一些(自定义),内存管理器/分配器,通过一些文章,去 -

有些链接:

我有使用任何可用的一个沙箱一个小型Web服务器,我有书面的包装线程处理/分配方案没有问题。 Apache的WS使用内存池,用于处理内存和池不是持久的,它是每个请求的基础。你们可以建议的东西吗?这个问题的一些好的/最好的方法?我的要求如下; -


  1. (有界响应时间)的分配和解除分配有事先是已知的,即一些
    成本不变O(C),其中c是
    恒定的。


  2. 从异构碎片
        分配/解除分配的大小或
        顺序应该如何处理,我可以写的模式/封装提供
        一样的。


真正的AP preciate您的帮助和想法!


解决方案

  

从异构碎片
  分配/解除分配的大小或
  顺序应该如何处理,我可以
  写模式/包装提供
  相同。


要避免碎片,你将不得不使用混合块分配策略。这里指混合比具有单一尺寸的单元块,即分配器(或围绕它的包装)应保持不同大小的元素(小,中,大等)的块大小不同的元素块。所有分配请求应四舍五入到最接近的块边界。这一策略应确保您不会从外部碎片受苦,但可能会导致内部碎片。您可以在下面的链接的详细信息:

http://www.cotsjournalonline.com/magazine/articles/查看/ 101217 / PG:2
http://people.freebsd.org/~jasone/jemalloc/bsdcan2006/jemalloc.pdf

I looking for some (custom) memory managers/allocator written in c and went through some articles, -

Some Links :

I have to sandbox a small web-server using any available one and I have no problem in writing wrappers for thread handling / allocation scheme. Apache WS uses memory pools for handling memory and the pools are not persistent, it is per-request basis. Can you guys suggest something? Some good / best approach to this problem ? My requirements are as below ;-

  1. (Bounded Response Time) allocation and de-allocation has to be known in advance, i.e some constant cost O(c), where c is constant.

  2. Fragmentation from heterogeneous allocation/de-allocation sizes or sequences should be handled, I can write the schema / wrapper to provide the same.

Truly appreciate you help and ideas!

解决方案

Fragmentation from heterogeneous allocation/de-allocation sizes or sequences should be handled, I can write the schema / wrapper to provide the same.

To avoid fragmentation, you will have to use a hybrid block allocation strategy. Hybrid here means different sized element blocks than having single sized element blocks i.e. The allocator (or a wrapper around it) should maintain blocks of different-sized elements(small, medium and large etc.). All allocation requests should be rounded up to the nearest block boundary. This strategy shall ensure you will not suffer from external fragmentation but can cause internal fragmentation. You can find more info at the following links:

http://www.cotsjournalonline.com/magazine/articles/view/101217/pg:2 http://people.freebsd.org/~jasone/jemalloc/bsdcan2006/jemalloc.pdf

这篇关于自定义内存分配器在C /经理吗?哪种方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆