40 #define MaxAllocSize ((Size) 0x3fffffff)
42 #define AllocSizeIsValid(size) ((Size) (size) <= MaxAllocSize)
44 #define MaxAllocHugeSize (SIZE_MAX / 2)
46 #define AllocHugeSizeIsValid(size) ((Size) (size) <= MaxAllocHugeSize)
67 #define MemoryContextResetAndDeleteChildren(ctx) MemoryContextReset(ctx)
88 bool print_to_stderr);
92 #ifdef MEMORY_CONTEXT_CHECKING
98 #define MemoryContextCopyAndSetIdentifier(cxt, id) \
99 MemoryContextSetIdentifier(cxt, MemoryContextStrdup(cxt, id))
129 context = *(
MemoryContext *) (((
char *) pointer) -
sizeof(
void *));
167 #ifdef HAVE__BUILTIN_CONSTANT_P
168 #define AllocSetContextCreate(parent, name, ...) \
169 (StaticAssertExpr(__builtin_constant_p(name), \
170 "memory context names must be constant strings"), \
171 AllocSetContextCreateInternal(parent, name, __VA_ARGS__))
173 #define AllocSetContextCreate \
174 AllocSetContextCreateInternal
194 #define ALLOCSET_DEFAULT_MINSIZE 0
195 #define ALLOCSET_DEFAULT_INITSIZE (8 * 1024)
196 #define ALLOCSET_DEFAULT_MAXSIZE (8 * 1024 * 1024)
197 #define ALLOCSET_DEFAULT_SIZES \
198 ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
204 #define ALLOCSET_SMALL_MINSIZE 0
205 #define ALLOCSET_SMALL_INITSIZE (1 * 1024)
206 #define ALLOCSET_SMALL_MAXSIZE (8 * 1024)
207 #define ALLOCSET_SMALL_SIZES \
208 ALLOCSET_SMALL_MINSIZE, ALLOCSET_SMALL_INITSIZE, ALLOCSET_SMALL_MAXSIZE
214 #define ALLOCSET_START_SMALL_SIZES \
215 ALLOCSET_SMALL_MINSIZE, ALLOCSET_SMALL_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
224 #define ALLOCSET_SEPARATE_THRESHOLD 8192
226 #define SLAB_DEFAULT_BLOCK_SIZE (8 * 1024)
227 #define SLAB_LARGE_BLOCK_SIZE (8 * 1024 * 1024)
#define AssertArg(condition)
Assert(fmt[strlen(fmt) - 1] !='\n')
#define MemoryContextIsValid(context)
PGDLLIMPORT MemoryContext CurTransactionContext
bool MemoryContextIsEmpty(MemoryContext context)
void MemoryContextReset(MemoryContext context)
PGDLLIMPORT MemoryContext MessageContext
PGDLLIMPORT MemoryContext TopMemoryContext
PGDLLIMPORT MemoryContext TopTransactionContext
void HandleLogMemoryContextInterrupt(void)
void MemoryContextSetParent(MemoryContext context, MemoryContext new_parent)
void MemoryContextStatsDetail(MemoryContext context, int max_children, bool print_to_stderr)
Size GetMemoryChunkSpace(void *pointer)
void MemoryContextDeleteChildren(MemoryContext context)
static MemoryContext GetMemoryChunkContext(void *pointer)
PGDLLIMPORT MemoryContext PostmasterContext
Size MemoryContextMemAllocated(MemoryContext context, bool recurse)
void MemoryContextStats(MemoryContext context)
MemoryContext SlabContextCreate(MemoryContext parent, const char *name, Size blockSize, Size chunkSize)
void MemoryContextInit(void)
bool MemoryContextContains(MemoryContext context, void *pointer)
PGDLLIMPORT MemoryContext CacheMemoryContext
MemoryContext MemoryContextGetParent(MemoryContext context)
void ProcessLogMemoryContextInterrupt(void)
PGDLLIMPORT MemoryContext PortalContext
MemoryContext GenerationContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
void MemoryContextCreate(MemoryContext node, NodeTag tag, const MemoryContextMethods *methods, MemoryContext parent, const char *name)
void MemoryContextDelete(MemoryContext context)
void MemoryContextAllowInCriticalSection(MemoryContext context, bool allow)
void MemoryContextResetChildren(MemoryContext context)
void MemoryContextSetIdentifier(MemoryContext context, const char *id)
void MemoryContextResetOnly(MemoryContext context)
PGDLLIMPORT MemoryContext ErrorContext
MemoryContext AllocSetContextCreateInternal(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)