什么是Slab 分配器,如何理解这个slab 机制

科技资讯 投稿 47700 0 评论

什么是Slab 分配器,如何理解这个slab 机制

1、什么是Slab 分配器:

Slab  firstly introduced in kernel 2.2, it's now one of three memory allocator implementations together with SLOB and SLUB. The three allocators provides a kind of front-end to the zoned buddy allocator for those sections of the kernel that require more flexible memory allocation than the standard 4KB page size

2、如何理解这个slab 机制:

我对Slab 分配器的理解是,slab 层应该是软件层面的一种内存管理机制,它把不同的对象划分为不同的高速缓存组(空闲链表),每一个高速缓存组针对一种类型的对象,例如一个只存task_struct的高速缓存组。
然后某一个高速缓存组有包含不同状态的slab(满,半满,空),然后slab是由一个或多个物理上连续的页组成的。
Slab allocation 相当于给内存做了一层缓存,释放对象也不是真的释放掉,而是给个标记,如果下次同类型的对象要申请空间,直接在slab里面找标记为空闲的某块区域,直接分配。这样可以高效的应对小空间对象频繁的申请和释放。

编程笔记 » 什么是Slab 分配器,如何理解这个slab 机制

赞同 (32) or 分享 (0)
游客 发表我的评论   换个身份
取消评论

表情
(0)个小伙伴在吐槽