swoole版本:1.7.4-stable
Swoole中为了更好的进行内存管理,减少频繁分配释放内存空间造成的损耗和内存碎片,Rango设计并实现了三种不同功能的MemoryPool:FixedPool,RingBuffer和MemoryGlobal。
Rango声明了一个swMemoryPool结构体来表示一个内存池,该结构体在swoole.h头文件中501-507行声明,结构如下:
typedef struct _swMemoryPool
{
void*object;
void*(*alloc)(struct _swMemoryPool *pool, uint32_t size);
void(*free)(struct _swMemoryPool *pool, void *ptr);
void(*destroy)(struct _swMemoryPool *pool);
} swMemoryPool;