mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
to make a reasonable attempt at accounting for palloc overhead, not just the requested size of each memory chunk. Since in many scenarios this will make for a significant reduction in the amount of space acquired, partially compensate by doubling the default value of SORT_MEM to 1Mb. Per discussion in pgsql-general around 9-Jun-2002..
77 lines
2.5 KiB
C
77 lines
2.5 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* memnodes.h
|
|
* POSTGRES memory context node definitions.
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* $Id: memnodes.h,v 1.25 2002/08/12 00:36:12 tgl Exp $
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef MEMNODES_H
|
|
#define MEMNODES_H
|
|
|
|
#include "nodes/nodes.h"
|
|
|
|
/*
|
|
* MemoryContext
|
|
* A logical context in which memory allocations occur.
|
|
*
|
|
* MemoryContext itself is an abstract type that can have multiple
|
|
* implementations, though for now we have only AllocSetContext.
|
|
* The function pointers in MemoryContextMethods define one specific
|
|
* implementation of MemoryContext --- they are a virtual function table
|
|
* in C++ terms.
|
|
*
|
|
* Node types that are actual implementations of memory contexts must
|
|
* begin with the same fields as MemoryContext.
|
|
*
|
|
* Note: for largely historical reasons, typedef MemoryContext is a pointer
|
|
* to the context struct rather than the struct type itself.
|
|
*/
|
|
|
|
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);
|
|
void (*stats) (MemoryContext context);
|
|
#ifdef MEMORY_CONTEXT_CHECKING
|
|
void (*check) (MemoryContext context);
|
|
#endif
|
|
} MemoryContextMethods;
|
|
|
|
|
|
typedef struct MemoryContextData
|
|
{
|
|
NodeTag type; /* identifies exact kind of context */
|
|
MemoryContextMethods *methods; /* virtual function table */
|
|
MemoryContext parent; /* NULL if no parent (toplevel context) */
|
|
MemoryContext firstchild; /* head of linked list of children */
|
|
MemoryContext nextchild; /* next child of same parent */
|
|
char *name; /* context name (just for debugging) */
|
|
} MemoryContextData;
|
|
|
|
/* utils/palloc.h contains typedef struct MemoryContextData *MemoryContext */
|
|
|
|
|
|
/*
|
|
* MemoryContextIsValid
|
|
* True iff memory context is valid.
|
|
*
|
|
* Add new context types to the set accepted by this macro.
|
|
*/
|
|
#define MemoryContextIsValid(context) \
|
|
((context) != NULL && \
|
|
(IsA((context), AllocSetContext)))
|
|
|
|
#endif /* MEMNODES_H */
|