+ -
当前位置:首页 → 问答吧 → 问下 建链表会不会造成大量内存碎片

问下 建链表会不会造成大量内存碎片

时间:2011-12-27

来源:互联网

如果我定义链表
struct a{
  int n;
  struct *next;
};
如果我需要建立一个几亿级别的链表,会不会造成大量的内存碎片
有没有比较好的方法

我想写个内存修改器,需要记录搜索的内存地址

作者: flyrack   发布时间: 2011-12-27

自己试一下就知道啦。

作者: taodm   发布时间: 2011-12-27

怎样试啊??大神说明一下可以吗??真心不懂

作者: zwb8848happy   发布时间: 2011-12-27

内存碎片又分为内部碎片和外部碎片

Internal fragmentation occurs when an allocated block is larger than the payload. This might happen for a number of reasons. For example, the implementation of an allocator might impose a minimum size on allocated blocks that is greater than some requested payload.  
Internal fragmentation is straightforward to quantify. It is simply the sum of the differences between the sizes of the allocated blocks and their payloads. Thus, at any point in time, the amount of internal fragmentation depends only on the pattern of previous requests and the allocator implementation

External fragmentation is much more difficult to quantify than internal fragmentation because it depends not only on the pattern of previous requests and the allocator implementation, but also on the pattern of future requests.

作者: AnYidan   发布时间: 2011-12-27

操作系统会尽量利用好内存,避免碎片的,不用我们操心吧
空间配置器简单实现:
http://blog.csdn.net/yafeng_jiang/article/details/6988490

作者: yafeng_jiang   发布时间: 2011-12-27