ACE_Allocator,ACE 中 的 分 配 器 类 的 接 口 类 ; ACE_Stac_Allocator ,管理固定大小的内存;
ACE_Cached_Allocator , 预 先 分 配 内 存 池 , 其 中 含 有 特 定 数 目 和 大 小 的 内 存 chunk ;
ACE_New_Allocator,为 C++ new 和 delete 操作符提供包装的分配器,内部使用 new 和 delete 操
作符,以满足动
分配器描述
ACE_Allocator
ACE 中的分配器类的接口类。这些类使用继承和动态绑定来提供灵活性。
ACE_Static_Allocator
该分配器管理固定大小的内存。每当收到分配内存的请求时,它就移动内部指针、以返回内存
chunk(“大块”)。它还假定内存一旦被分配,就再也不会被释放。
ACE_Cached_Allocator
该分配器预先分配内存池,其中含有特定数目和大小的内存 chunk。这些 chunk 在内部空闲
表(free list)中进行维护,并在收到内存请求(malloc())时被返回。当应用调用 free()时,
chunk 被归还到内部空闲表、而不是 OS 中。
ACE_New_Allocator
为 C++ new 和 delete 操作符提供包装的分配器,也就是,它在内部使用 new 和 delete 操
作符,以满足动态内存请求。
#include " ace/Malloc.h "
// Achunkofsize1Kiscreated.Inourcasewedecidedtouseasimplearray
// asthetypeforthechunk.Insteadofthiswecoulduseanystructorclass
// thatwethinkisappropriate.
typedef char MEMORY_BLOCK[ 1024 ];
// CreateanACE_Cached_Allocatorwhichispassedinthetypeofthe
// “chunk”thatitmustpre-allocateandassignonthefreelist.
// SincetheCached_Allocatorisatemplateclasswecanprettymuch
// passitANYtypewethinkisappropriatetobeamemoryblock.
typedefACE_Cached_Allocator < MEMORY_BLOCK,ACE_SYNCH_MUTEX >
Allocator;
评论0