日期:2014-05-16  浏览次数:20388 次

pg的内存管理机制一:AllocSet的内存分配

1 AllocSet 的内存分配涉及到的方法和数据结构

话说

MemoryContextMethods 结构里的函数实现了pgAllocSetMemoryContext 的内存管理机制,定义见下面。

?

?

typedef struct MemoryContextMethods

{

???? void ?? *(*alloc) (MemoryContext context, Size size);

???? /* call this free_p in case someone #define's free() */

???? void ???? (*free_p) (MemoryContext context, void *pointer);

???? void ?? *(*realloc) (MemoryContext context, void *pointer, Size size);

???? void ???? (*init) (MemoryContext context);

???? void ???? (*reset) (MemoryContext context);

???? void ???? (*delete ) (MemoryContext context);

???? Size???? (*get_chunk_space) (MemoryContext context, void *pointer);

???? bool ???? (*is_empty) (MemoryContext context);

???? void ???? (*stats) (MemoryContext context);

#ifdef MEMORY_CONTEXT_