PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
memutils.h File Reference
#include "nodes/memnodes.h"
Include dependency graph for memutils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MaxAllocSize   ((Size) 0x3fffffff) /* 1 gigabyte - 1 */
 
#define AllocSizeIsValid(size)   ((Size) (size) <= MaxAllocSize)
 
#define MaxAllocHugeSize   ((Size) -1 >> 1) /* SIZE_MAX / 2 */
 
#define AllocHugeSizeIsValid(size)   ((Size) (size) <= MaxAllocHugeSize)
 
#define MemoryContextResetAndDeleteChildren(ctx)   MemoryContextReset(ctx)
 
#define ALLOCSET_DEFAULT_MINSIZE   0
 
#define ALLOCSET_DEFAULT_INITSIZE   (8 * 1024)
 
#define ALLOCSET_DEFAULT_MAXSIZE   (8 * 1024 * 1024)
 
#define ALLOCSET_DEFAULT_SIZES   ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
 
#define ALLOCSET_SMALL_MINSIZE   0
 
#define ALLOCSET_SMALL_INITSIZE   (1 * 1024)
 
#define ALLOCSET_SMALL_MAXSIZE   (8 * 1024)
 
#define ALLOCSET_SMALL_SIZES   ALLOCSET_SMALL_MINSIZE, ALLOCSET_SMALL_INITSIZE, ALLOCSET_SMALL_MAXSIZE
 
#define ALLOCSET_START_SMALL_SIZES   ALLOCSET_SMALL_MINSIZE, ALLOCSET_SMALL_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE
 
#define ALLOCSET_SEPARATE_THRESHOLD   8192
 
#define SLAB_DEFAULT_BLOCK_SIZE   (8 * 1024)
 
#define SLAB_LARGE_BLOCK_SIZE   (8 * 1024 * 1024)
 

Functions

void MemoryContextInit (void)
 
void MemoryContextReset (MemoryContext context)
 
void MemoryContextDelete (MemoryContext context)
 
void MemoryContextResetOnly (MemoryContext context)
 
void MemoryContextResetChildren (MemoryContext context)
 
void MemoryContextDeleteChildren (MemoryContext context)
 
void MemoryContextSetParent (MemoryContext context, MemoryContext new_parent)
 
Size GetMemoryChunkSpace (void *pointer)
 
MemoryContext MemoryContextGetParent (MemoryContext context)
 
bool MemoryContextIsEmpty (MemoryContext context)
 
void MemoryContextStats (MemoryContext context)
 
void MemoryContextStatsDetail (MemoryContext context, int max_children)
 
void MemoryContextAllowInCriticalSection (MemoryContext context, bool allow)
 
bool MemoryContextContains (MemoryContext context, void *pointer)
 
static MemoryContext GetMemoryChunkContext (void *pointer)
 
MemoryContext MemoryContextCreate (NodeTag tag, Size size, MemoryContextMethods *methods, MemoryContext parent, const char *name)
 
MemoryContext AllocSetContextCreate (MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
 
MemoryContext SlabContextCreate (MemoryContext parent, const char *name, Size blockSize, Size chunkSize)
 

Variables

PGDLLIMPORT MemoryContext TopMemoryContext
 
PGDLLIMPORT MemoryContext ErrorContext
 
PGDLLIMPORT MemoryContext PostmasterContext
 
PGDLLIMPORT MemoryContext CacheMemoryContext
 
PGDLLIMPORT MemoryContext MessageContext
 
PGDLLIMPORT MemoryContext TopTransactionContext
 
PGDLLIMPORT MemoryContext CurTransactionContext
 
PGDLLIMPORT MemoryContext PortalContext
 

Macro Definition Documentation

#define AllocHugeSizeIsValid (   size)    ((Size) (size) <= MaxAllocHugeSize)
#define ALLOCSET_DEFAULT_INITSIZE   (8 * 1024)
#define ALLOCSET_DEFAULT_MAXSIZE   (8 * 1024 * 1024)
#define ALLOCSET_DEFAULT_MINSIZE   0

Definition at line 165 of file memutils.h.

Referenced by afterTriggerAddEvent(), afterTriggerInvokeEvents(), AllocateSnapshotBuilder(), ApplyWorkerMain(), AtStart_Memory(), AtSubStart_Memory(), AutoVacLauncherMain(), BackgroundWriterMain(), begin_heap_rewrite(), BeginCopy(), blbuild(), blinsert(), brin_new_memtuple(), bringetbitmap(), brininsert(), btvacuumscan(), BuildEventTriggerCache(), CheckpointerMain(), cluster(), compute_index_stats(), CopyTo(), CreateCacheMemoryContext(), CreateExecutorState(), CreateExprContext(), CreateStandaloneExprContext(), createTempGistContext(), createTrgmNFA(), do_analyze_rel(), do_autovacuum(), do_compile(), do_start_worker(), each_worker(), each_worker_jsonb(), elements_worker(), elements_worker_jsonb(), EnablePortalManager(), EventTriggerBeginCompleteQuery(), EventTriggerInvoke(), exec_parse_message(), exec_replication_command(), ExecHashTableCreate(), ExecInitFunctionScan(), ExecInitRecursiveUnion(), ExecInitSetOp(), ExecInitSubPlan(), ExecInitTableFuncScan(), ExecInitUnique(), ExecInitWindowAgg(), file_acquire_sample_rows(), find_all_inheritors(), geqo_eval(), get_stmt_mcontext(), GetLocalBufferStorage(), gin_xlog_startup(), ginbeginscan(), ginbuild(), ginbulkdelete(), gininsert(), ginInsertCleanup(), ginPlaceToPage(), gistrescan(), HandleParallelMessages(), hash_create(), index_register(), init_sql_fcache(), initArrayResult(), initArrayResultArr(), initGISTstate(), initialize_peragg(), InitXLogInsert(), inline_function(), inline_set_returning_function(), libpqrcv_processTuples(), logicalrep_relmap_init(), make_sure_stat_tab_initialized(), materializeQueryResult(), mdinit(), MemoryContextInit(), NIStartBuild(), ParallelWorkerMain(), PerformAuthentication(), pg_decode_startup(), plperl_return_next(), plperl_spi_prepare(), plpgsql_compile_inline(), plpgsql_estate_setup(), plpython_inline_handler(), PLy_cursor_plan(), PLy_cursor_query(), PLy_get_scratch_context(), PLy_procedure_create(), PLy_spi_execute_fetch_result(), PLy_spi_prepare(), PLyObject_ToComposite(), PLyString_ToComposite(), PortalCreateHoldStore(), postgresBeginForeignScan(), PostgresMain(), PostmasterMain(), printtup_startup(), rebuild_database_list(), RelationBuildPartitionDesc(), ReorderBufferAllocate(), ResetUnloggedRelations(), sepgsql_avc_init(), spg_xlog_startup(), spgbeginscan(), spgbuild(), spginsert(), SPI_connect(), spi_dest_startup(), StartupDecodingContext(), strlist_to_textarray(), tqueueReceiveSlot(), tuplesort_begin_common(), union_tuples(), vacuum(), WalWriterMain(), and XLOGShmemInit().

#define ALLOCSET_SEPARATE_THRESHOLD   8192
#define ALLOCSET_SMALL_INITSIZE   (1 * 1024)

Definition at line 173 of file memutils.h.

Referenced by DiscreteKnapsack(), and get_agg_clause_costs_walker().

#define ALLOCSET_SMALL_MAXSIZE   (8 * 1024)

Definition at line 174 of file memutils.h.

Referenced by DiscreteKnapsack().

#define ALLOCSET_SMALL_MINSIZE   0

Definition at line 172 of file memutils.h.

Referenced by DiscreteKnapsack().

#define MaxAllocHugeSize   ((Size) -1 >> 1) /* SIZE_MAX / 2 */

Definition at line 44 of file memutils.h.

Referenced by grow_memtuples(), and qtext_load_file().

#define SLAB_DEFAULT_BLOCK_SIZE   (8 * 1024)

Definition at line 194 of file memutils.h.

Referenced by ReorderBufferAllocate().

#define SLAB_LARGE_BLOCK_SIZE   (8 * 1024 * 1024)

Definition at line 195 of file memutils.h.

Function Documentation

MemoryContext AllocSetContextCreate ( MemoryContext  parent,
const char *  name,
Size  minContextSize,
Size  initBlockSize,
Size  maxBlockSize 
)

Definition at line 322 of file aset.c.

References ALLOC_BLOCKHDRSZ, ALLOC_CHUNK_FRACTION, ALLOC_CHUNK_LIMIT, ALLOC_CHUNKHDRSZ, AllocSetContext::allocChunkLimit, AllocHugeSizeIsValid, ALLOCSET_SEPARATE_THRESHOLD, AllocSetMethods, AllocBlockData::aset, AllocSetContext::blocks, elog, AllocBlockData::endptr, ereport, errcode(), errdetail(), errmsg(), ERROR, AllocBlockData::freeptr, AllocSetContext::initBlockSize, AllocSetContext::keeper, malloc, MAXALIGN, AllocSetContext::maxBlockSize, MemoryContextCreate(), MemoryContextStats(), name, AllocBlockData::next, AllocSetContext::nextBlockSize, NULL, offsetof, AllocBlockData::prev, StaticAssertStmt, T_AllocSetContext, TopMemoryContext, and VALGRIND_MAKE_MEM_NOACCESS.

Referenced by _bt_preprocess_array_keys(), _SPI_make_plan_non_temp(), _SPI_save_plan(), afterTriggerAddEvent(), afterTriggerInvokeEvents(), AllocateSnapshotBuilder(), ApplyLauncherMain(), ApplyWorkerMain(), AtStart_Memory(), AtSubStart_Memory(), AutoVacLauncherMain(), BackgroundWriterMain(), begin_heap_rewrite(), BeginCopy(), blbuild(), blinsert(), brin_build_desc(), brin_new_memtuple(), bringetbitmap(), brininsert(), bt_check_every_level(), btvacuumscan(), BuildCachedPlan(), BuildEventTriggerCache(), CheckpointerMain(), cluster(), compile_plperl_function(), compile_pltcl_function(), CompleteCachedPlan(), compute_index_stats(), CopyCachedPlan(), CopyTo(), CreateCachedPlan(), CreateCacheMemoryContext(), CreateExecutorState(), CreateExprContext(), CreatePortal(), CreateStandaloneExprContext(), createTempGistContext(), createTrgmNFA(), DiscreteKnapsack(), do_analyze_rel(), do_autovacuum(), do_compile(), do_start_worker(), each_worker(), each_worker_jsonb(), elements_worker(), elements_worker_jsonb(), EnablePortalManager(), EventTriggerBeginCompleteQuery(), EventTriggerInvoke(), exec_parse_message(), exec_replication_command(), ExecHashTableCreate(), ExecInitFunctionScan(), ExecInitRecursiveUnion(), ExecInitSetOp(), ExecInitSubPlan(), ExecInitTableFuncScan(), ExecInitUnique(), ExecInitWindowAgg(), expand_array(), file_acquire_sample_rows(), fill_hba_view(), find_all_inheritors(), geqo_eval(), get_stmt_mcontext(), GetLocalBufferStorage(), gin_xlog_startup(), ginbeginscan(), ginbuild(), ginbulkdelete(), gininsert(), ginInsertCleanup(), ginPlaceToPage(), gistrescan(), HandleParallelMessages(), hash_create(), index_register(), init_MultiFuncCall(), init_sql_fcache(), initArrayResult(), initArrayResultArr(), initGISTstate(), initialize_peragg(), InitXLogInsert(), inline_function(), inline_set_returning_function(), libpqrcv_processTuples(), load_domaintype_info(), load_hba(), load_ident(), load_relcache_init_file(), load_tzoffsets(), logicalrep_relmap_init(), LogicalRepApplyLoop(), lookup_ts_dictionary_cache(), make_sure_stat_tab_initialized(), materializeQueryResult(), mdinit(), MemoryContextInit(), mXactCachePut(), NIStartBuild(), ParallelWorkerMain(), PerformAuthentication(), pg_decode_startup(), pgoutput_startup(), pgstat_setup_memcxt(), plperl_return_next(), plperl_spi_prepare(), plpgsql_compile_inline(), plpgsql_estate_setup(), plpython_inline_handler(), pltcl_SPI_prepare(), PLy_cursor_plan(), PLy_cursor_query(), PLy_get_scratch_context(), PLy_procedure_create(), PLy_spi_execute_fetch_result(), PLy_spi_prepare(), PLyObject_ToComposite(), PLyString_ToComposite(), PortalCreateHoldStore(), postgresAcquireSampleRowsFunc(), postgresBeginDirectModify(), postgresBeginForeignModify(), postgresBeginForeignScan(), PostgresMain(), PostmasterMain(), printtup_startup(), publicationListToArray(), rebuild_database_list(), ReindexMultipleTables(), RelationBuildPartitionDesc(), RelationBuildPartitionKey(), RelationBuildRowSecurity(), RelationBuildRuleLock(), RelationInitIndexAccessInfo(), ReorderBufferAllocate(), ResetUnloggedRelations(), RevalidateCachedQuery(), sepgsql_avc_init(), spg_xlog_startup(), spgbeginscan(), spgbuild(), spginsert(), SPI_connect(), spi_dest_startup(), StartupDecodingContext(), strlist_to_textarray(), tokenize_file(), tqueueReceiveSlot(), tuplesort_begin_common(), union_tuples(), vacuum(), WalWriterMain(), and XLOGShmemInit().

327 {
328  AllocSet set;
329 
331  MAXALIGN(sizeof(AllocChunkData)),
332  "padding calculation in AllocChunkData is wrong");
333 
334  /*
335  * First, validate allocation parameters. (If we're going to throw an
336  * error, we should do so before the context is created, not after.) We
337  * somewhat arbitrarily enforce a minimum 1K block size.
338  */
339  if (initBlockSize != MAXALIGN(initBlockSize) ||
340  initBlockSize < 1024)
341  elog(ERROR, "invalid initBlockSize for memory context: %zu",
342  initBlockSize);
343  if (maxBlockSize != MAXALIGN(maxBlockSize) ||
344  maxBlockSize < initBlockSize ||
345  !AllocHugeSizeIsValid(maxBlockSize)) /* must be safe to double */
346  elog(ERROR, "invalid maxBlockSize for memory context: %zu",
347  maxBlockSize);
348  if (minContextSize != 0 &&
349  (minContextSize != MAXALIGN(minContextSize) ||
350  minContextSize <= ALLOC_BLOCKHDRSZ + ALLOC_CHUNKHDRSZ))
351  elog(ERROR, "invalid minContextSize for memory context: %zu",
352  minContextSize);
353 
354  /* Do the type-independent part of context creation */
356  sizeof(AllocSetContext),
358  parent,
359  name);
360 
361  /* Save allocation parameters */
362  set->initBlockSize = initBlockSize;
363  set->maxBlockSize = maxBlockSize;
364  set->nextBlockSize = initBlockSize;
365 
366  /*
367  * Compute the allocation chunk size limit for this context. It can't be
368  * more than ALLOC_CHUNK_LIMIT because of the fixed number of freelists.
369  * If maxBlockSize is small then requests exceeding the maxBlockSize, or
370  * even a significant fraction of it, should be treated as large chunks
371  * too. For the typical case of maxBlockSize a power of 2, the chunk size
372  * limit will be at most 1/8th maxBlockSize, so that given a stream of
373  * requests that are all the maximum chunk size we will waste at most
374  * 1/8th of the allocated space.
375  *
376  * We have to have allocChunkLimit a power of two, because the requested
377  * and actually-allocated sizes of any chunk must be on the same side of
378  * the limit, else we get confused about whether the chunk is "big".
379  *
380  * Also, allocChunkLimit must not exceed ALLOCSET_SEPARATE_THRESHOLD.
381  */
383  "ALLOC_CHUNK_LIMIT != ALLOCSET_SEPARATE_THRESHOLD");
384 
386  while ((Size) (set->allocChunkLimit + ALLOC_CHUNKHDRSZ) >
387  (Size) ((maxBlockSize - ALLOC_BLOCKHDRSZ) / ALLOC_CHUNK_FRACTION))
388  set->allocChunkLimit >>= 1;
389 
390  /*
391  * Grab always-allocated space, if requested
392  */
393  if (minContextSize > 0)
394  {
395  Size blksize = minContextSize;
396  AllocBlock block;
397 
398  block = (AllocBlock) malloc(blksize);
399  if (block == NULL)
400  {
402  ereport(ERROR,
403  (errcode(ERRCODE_OUT_OF_MEMORY),
404  errmsg("out of memory"),
405  errdetail("Failed while creating memory context \"%s\".",
406  name)));
407  }
408  block->aset = set;
409  block->freeptr = ((char *) block) + ALLOC_BLOCKHDRSZ;
410  block->endptr = ((char *) block) + blksize;
411  block->prev = NULL;
412  block->next = set->blocks;
413  if (block->next)
414  block->next->prev = block;
415  set->blocks = block;
416  /* Mark block as not to be released at reset time */
417  set->keeper = block;
418 
419  /* Mark unallocated space NOACCESS; leave the block header alone. */
421  blksize - ALLOC_BLOCKHDRSZ);
422  }
423 
424  return (MemoryContext) set;
425 }
Size initBlockSize
Definition: aset.c:127
AllocBlock blocks
Definition: aset.c:124
#define VALGRIND_MAKE_MEM_NOACCESS(addr, size)
Definition: memdebug.h:27
int errcode(int sqlerrcode)
Definition: elog.c:575
#define ALLOC_BLOCKHDRSZ
Definition: aset.c:99
AllocBlock keeper
Definition: aset.c:131
AllocSet aset
Definition: aset.c:150
char * freeptr
Definition: aset.c:153
#define malloc(a)
Definition: header.h:50
#define StaticAssertStmt(condition, errmessage)
Definition: c.h:757
#define ERROR
Definition: elog.h:43
#define ALLOC_CHUNK_LIMIT
Definition: aset.c:83
void MemoryContextStats(MemoryContext context)
Definition: mcxt.c:438
char * endptr
Definition: aset.c:154
#define ALLOCSET_SEPARATE_THRESHOLD
Definition: memutils.h:192
int errdetail(const char *fmt,...)
Definition: elog.c:873
MemoryContext MemoryContextCreate(NodeTag tag, Size size, MemoryContextMethods *methods, MemoryContext parent, const char *name)
Definition: mcxt.c:640
#define ALLOC_CHUNKHDRSZ
Definition: aset.c:100
static MemoryContextMethods AllocSetMethods
Definition: aset.c:219
AllocBlock next
Definition: aset.c:152
#define ereport(elevel, rest)
Definition: elog.h:122
MemoryContext TopMemoryContext
Definition: mcxt.c:43
#define ALLOC_CHUNK_FRACTION
Definition: aset.c:85
struct AllocBlockData * AllocBlock
Definition: aset.c:102
Size nextBlockSize
Definition: aset.c:129
AllocBlock prev
Definition: aset.c:151
Size allocChunkLimit
Definition: aset.c:130
#define NULL
Definition: c.h:229
size_t Size
Definition: c.h:356
#define MAXALIGN(LEN)
Definition: c.h:588
const char * name
Definition: encode.c:521
#define AllocHugeSizeIsValid(size)
Definition: memutils.h:46
int errmsg(const char *fmt,...)
Definition: elog.c:797
AllocSetContext * AllocSet
Definition: aset.c:134
#define elog
Definition: elog.h:219
Size maxBlockSize
Definition: aset.c:128
#define offsetof(type, field)
Definition: c.h:555
static MemoryContext GetMemoryChunkContext ( void *  pointer)
inlinestatic

Definition at line 107 of file memutils.h.

References Assert, AssertArg, MAXALIGN, MemoryContextIsValid, and NULL.

Referenced by GetMemoryChunkSpace(), mark_dummy_rel(), pfree(), repalloc(), and repalloc_huge().

108 {
109  MemoryContext context;
110 
111  /*
112  * Try to detect bogus pointers handed to us, poorly though we can.
113  * Presumably, a pointer that isn't MAXALIGNED isn't pointing at an
114  * allocated chunk.
115  */
116  Assert(pointer != NULL);
117  Assert(pointer == (void *) MAXALIGN(pointer));
118 
119  /*
120  * OK, it's probably safe to look at the context.
121  */
122  context = *(MemoryContext *) (((char *) pointer) - sizeof(void *));
123 
125 
126  return context;
127 }
#define AssertArg(condition)
Definition: c.h:677
#define MemoryContextIsValid(context)
Definition: memnodes.h:97
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
#define MAXALIGN(LEN)
Definition: c.h:588
void MemoryContextAllowInCriticalSection ( MemoryContext  context,
bool  allow 
)

Definition at line 374 of file mcxt.c.

References MemoryContextData::allowInCritSection, AssertArg, and MemoryContextIsValid.

Referenced by mdinit(), MemoryContextInit(), and XLOGShmemInit().

375 {
377 
378  context->allowInCritSection = allow;
379 }
bool allowInCritSection
Definition: memnodes.h:78
#define AssertArg(condition)
Definition: c.h:677
#define MemoryContextIsValid(context)
Definition: memnodes.h:97
bool MemoryContextContains ( MemoryContext  context,
void *  pointer 
)

Definition at line 567 of file mcxt.c.

References MAXALIGN, and NULL.

Referenced by eval_windowfunction(), finalize_aggregate(), finalize_partialaggregate(), and finalize_windowaggregate().

568 {
569  MemoryContext ptr_context;
570 
571  /*
572  * NB: Can't use GetMemoryChunkContext() here - that performs assertions
573  * that aren't acceptable here since we might be passed memory not
574  * allocated by any memory context.
575  *
576  * Try to detect bogus pointers handed to us, poorly though we can.
577  * Presumably, a pointer that isn't MAXALIGNED isn't pointing at an
578  * allocated chunk.
579  */
580  if (pointer == NULL || pointer != (void *) MAXALIGN(pointer))
581  return false;
582 
583  /*
584  * OK, it's probably safe to look at the context.
585  */
586  ptr_context = *(MemoryContext *) (((char *) pointer) - sizeof(void *));
587 
588  return ptr_context == context;
589 }
#define NULL
Definition: c.h:229
#define MAXALIGN(LEN)
Definition: c.h:588
MemoryContext MemoryContextCreate ( NodeTag  tag,
Size  size,
MemoryContextMethods methods,
MemoryContext  parent,
const char *  name 
)

Definition at line 640 of file mcxt.c.

References MemoryContextData::allowInCritSection, Assert, CritSectionCount, MemoryContextData::firstchild, MemoryContextMethods::init, MemoryContextData::isReset, malloc, MemoryContextAlloc(), MemSet, MemoryContextData::methods, MemoryContextData::name, MemoryContextData::nextchild, NULL, MemoryContextData::parent, MemoryContextData::prevchild, MemoryContextData::type, and VALGRIND_CREATE_MEMPOOL.

Referenced by AllocSetContextCreate(), and SlabContextCreate().

644 {
645  MemoryContext node;
646  Size needed = size + strlen(name) + 1;
647 
648  /* creating new memory contexts is not allowed in a critical section */
649  Assert(CritSectionCount == 0);
650 
651  /* Get space for node and name */
652  if (TopMemoryContext != NULL)
653  {
654  /* Normal case: allocate the node in TopMemoryContext */
656  needed);
657  }
658  else
659  {
660  /* Special case for startup: use good ol' malloc */
661  node = (MemoryContext) malloc(needed);
662  Assert(node != NULL);
663  }
664 
665  /* Initialize the node as best we can */
666  MemSet(node, 0, size);
667  node->type = tag;
668  node->methods = methods;
669  node->parent = NULL; /* for the moment */
670  node->firstchild = NULL;
671  node->prevchild = NULL;
672  node->nextchild = NULL;
673  node->isReset = true;
674  node->name = ((char *) node) + size;
675  strcpy(node->name, name);
676 
677  /* Type-specific routine finishes any other essential initialization */
678  (*node->methods->init) (node);
679 
680  /* OK to link node to parent (if any) */
681  /* Could use MemoryContextSetParent here, but doesn't seem worthwhile */
682  if (parent)
683  {
684  node->parent = parent;
685  node->nextchild = parent->firstchild;
686  if (parent->firstchild != NULL)
687  parent->firstchild->prevchild = node;
688  parent->firstchild = node;
689  /* inherit allowInCritSection flag from parent */
690  node->allowInCritSection = parent->allowInCritSection;
691  }
692 
693  VALGRIND_CREATE_MEMPOOL(node, 0, false);
694 
695  /* Return to type-specific creation routine to finish up */
696  return node;
697 }
MemoryContextMethods * methods
Definition: memnodes.h:79
bool allowInCritSection
Definition: memnodes.h:78
#define MemSet(start, val, len)
Definition: c.h:857
#define malloc(a)
Definition: header.h:50
MemoryContext firstchild
Definition: memnodes.h:81
MemoryContext prevchild
Definition: memnodes.h:82
volatile uint32 CritSectionCount
Definition: globals.c:36
MemoryContext TopMemoryContext
Definition: mcxt.c:43
struct MemoryContextData * MemoryContext
Definition: palloc.h:36
#define VALGRIND_CREATE_MEMPOOL(context, redzones, zeroed)
Definition: memdebug.h:24
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
size_t Size
Definition: c.h:356
const char * name
Definition: encode.c:521
void * MemoryContextAlloc(MemoryContext context, Size size)
Definition: mcxt.c:707
MemoryContext parent
Definition: memnodes.h:80
void(* init)(MemoryContext context)
Definition: memnodes.h:60
MemoryContext nextchild
Definition: memnodes.h:83
NodeTag type
Definition: memnodes.h:75
void MemoryContextDelete ( MemoryContext  context)

Definition at line 200 of file mcxt.c.

References Assert, AssertArg, MemoryContextMethods::delete_context, MemoryContextCallResetCallbacks(), MemoryContextDeleteChildren(), MemoryContextIsValid, MemoryContextSetParent(), MemoryContextData::methods, NULL, pfree(), and VALGRIND_DESTROY_MEMPOOL.

Referenced by AfterTriggerEndXact(), afterTriggerInvokeEvents(), ApplyLauncherMain(), AtCleanup_Memory(), AtCommit_Memory(), AtEOSubXact_SPI(), AtEOXact_LargeObject(), AtSubCleanup_Memory(), AtSubCommit_Memory(), blbuild(), blinsert(), brin_free_desc(), bringetbitmap(), brininsert(), bt_check_every_level(), btendscan(), btvacuumscan(), cluster(), compile_plperl_function(), compile_pltcl_function(), compute_index_stats(), CopyTo(), createTrgmNFA(), decr_dcc_refcount(), DeleteExpandedObject(), DiscreteKnapsack(), do_analyze_rel(), do_start_bgworker(), do_start_worker(), DropCachedPlan(), each_worker(), each_worker_jsonb(), elements_worker(), elements_worker_jsonb(), end_heap_rewrite(), EndCopy(), EventTriggerEndCompleteQuery(), EventTriggerInvoke(), exec_replication_command(), ExecEndRecursiveUnion(), ExecEndSetOp(), ExecEndUnique(), ExecEndWindowAgg(), ExecHashTableDestroy(), file_acquire_sample_rows(), fill_hba_view(), fmgr_sql(), free_plperl_function(), FreeDecodingContext(), FreeExecutorState(), FreeExprContext(), freeGISTstate(), FreeSnapshotBuilder(), geqo_eval(), gin_xlog_cleanup(), ginbuild(), ginbulkdelete(), ginendscan(), gininsert(), ginInsertCleanup(), ginPlaceToPage(), gist_xlog_cleanup(), gistbuild(), hash_destroy(), inline_function(), inline_set_returning_function(), libpqrcv_processTuples(), load_hba(), load_ident(), load_tzoffsets(), makeArrayResultArr(), makeMdArrayResult(), materializeQueryResult(), MemoryContextDeleteChildren(), mergeruns(), NIFinishBuild(), pg_decode_shutdown(), pgstat_clear_snapshot(), plperl_spi_freeplan(), plperl_spi_prepare(), plpgsql_free_function_memory(), pltcl_handler(), pltcl_SPI_prepare(), PLy_cursor_dealloc(), PLy_plan_dealloc(), PLy_pop_execution_context(), PLy_procedure_delete(), PLy_spi_execute_fetch_result(), PLyObject_ToComposite(), PLyString_ToComposite(), PortalDrop(), PostgresMain(), printtup_shutdown(), publicationListToArray(), rebuild_database_list(), ReindexMultipleTables(), RelationBuildRowSecurity(), RelationBuildRuleLock(), RelationDestroyRelation(), ReleaseCachedPlan(), ReorderBufferFree(), ResetUnloggedRelations(), RevalidateCachedQuery(), shutdown_MultiFuncCall(), spg_xlog_cleanup(), spgbuild(), spgendscan(), spginsert(), SPI_finish(), SPI_freeplan(), SPI_freetuptable(), StartChildProcess(), strlist_to_textarray(), tokenize_inc_file(), tqueueDestroyReceiver(), tuplesort_end(), union_tuples(), and vacuum().

201 {
203  /* We had better not be deleting TopMemoryContext ... */
204  Assert(context != TopMemoryContext);
205  /* And not CurrentMemoryContext, either */
206  Assert(context != CurrentMemoryContext);
207 
209 
210  /*
211  * It's not entirely clear whether 'tis better to do this before or after
212  * delinking the context; but an error in a callback will likely result in
213  * leaking the whole context (if it's not a root context) if we do it
214  * after, so let's do it before.
215  */
217 
218  /*
219  * We delink the context from its parent before deleting it, so that if
220  * there's an error we won't have deleted/busted contexts still attached
221  * to the context tree. Better a leak than a crash.
222  */
223  MemoryContextSetParent(context, NULL);
224 
225  (*context->methods->delete_context) (context);
226  VALGRIND_DESTROY_MEMPOOL(context);
227  pfree(context);
228 }
static void MemoryContextCallResetCallbacks(MemoryContext context)
Definition: mcxt.c:282
void MemoryContextSetParent(MemoryContext context, MemoryContext new_parent)
Definition: mcxt.c:317
MemoryContextMethods * methods
Definition: memnodes.h:79
void(* delete_context)(MemoryContext context)
Definition: memnodes.h:62
void pfree(void *pointer)
Definition: mcxt.c:950
MemoryContext CurrentMemoryContext
Definition: mcxt.c:37
#define AssertArg(condition)
Definition: c.h:677
MemoryContext TopMemoryContext
Definition: mcxt.c:43
void MemoryContextDeleteChildren(MemoryContext context)
Definition: mcxt.c:236
#define VALGRIND_DESTROY_MEMPOOL(context)
Definition: memdebug.h:25
#define MemoryContextIsValid(context)
Definition: memnodes.h:97
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
void MemoryContextDeleteChildren ( MemoryContext  context)

Definition at line 236 of file mcxt.c.

References AssertArg, MemoryContextData::firstchild, MemoryContextDelete(), MemoryContextIsValid, and NULL.

Referenced by AtAbort_Portals(), AtSubAbort_Portals(), exec_stmt_block(), MemoryContextDelete(), MemoryContextReset(), PersistHoldablePortal(), and PortalRunMulti().

237 {
239 
240  /*
241  * MemoryContextDelete will delink the child from me, so just iterate as
242  * long as there is a child.
243  */
244  while (context->firstchild != NULL)
246 }
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:200
MemoryContext firstchild
Definition: memnodes.h:81
#define AssertArg(condition)
Definition: c.h:677
#define MemoryContextIsValid(context)
Definition: memnodes.h:97
#define NULL
Definition: c.h:229
MemoryContext MemoryContextGetParent ( MemoryContext  context)

Definition at line 403 of file mcxt.c.

References AssertArg, MemoryContextIsValid, and MemoryContextData::parent.

Referenced by advance_combine_function(), advance_transition_function(), advance_windowaggregate(), advance_windowaggregate_base(), GetCachedPlan(), pop_stmt_mcontext(), and push_stmt_mcontext().

404 {
406 
407  return context->parent;
408 }
#define AssertArg(condition)
Definition: c.h:677
#define MemoryContextIsValid(context)
Definition: memnodes.h:97
MemoryContext parent
Definition: memnodes.h:80
void MemoryContextInit ( void  )

Definition at line 89 of file mcxt.c.

References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate(), AssertState, MemoryContextAllowInCriticalSection(), NULL, and TopMemoryContext.

Referenced by main().

90 {
92 
93  /*
94  * First, initialize TopMemoryContext, which will hold the MemoryContext
95  * nodes for all other contexts. (There is special-case code in
96  * MemoryContextCreate() to handle this call.)
97  */
99  "TopMemoryContext",
101 
102  /*
103  * Not having any other place to point CurrentMemoryContext, make it point
104  * to TopMemoryContext. Caller should change this soon!
105  */
107 
108  /*
109  * Initialize ErrorContext as an AllocSetContext with slow growth rate ---
110  * we don't really expect much to be allocated in it. More to the point,
111  * require it to contain at least 8K at all times. This is the only case
112  * where retained memory in a context is *essential* --- we want to be
113  * sure ErrorContext still has some memory even if we've run out
114  * elsewhere! Also, allow allocations in ErrorContext within a critical
115  * section. Otherwise a PANIC will cause an assertion failure in the error
116  * reporting code, before printing out the real cause of the failure.
117  *
118  * This should be the last step in this function, as elog.c assumes memory
119  * management works once ErrorContext is non-null.
120  */
122  "ErrorContext",
123  8 * 1024,
124  8 * 1024,
125  8 * 1024);
127 }
#define AssertState(condition)
Definition: c.h:678
void MemoryContextAllowInCriticalSection(MemoryContext context, bool allow)
Definition: mcxt.c:374
MemoryContext ErrorContext
Definition: mcxt.c:44
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:165
MemoryContext CurrentMemoryContext
Definition: mcxt.c:37
MemoryContext TopMemoryContext
Definition: mcxt.c:43
MemoryContext AllocSetContextCreate(MemoryContext parent, const char *name, Size minContextSize, Size initBlockSize, Size maxBlockSize)
Definition: aset.c:322
#define NULL
Definition: c.h:229
bool MemoryContextIsEmpty ( MemoryContext  context)

Definition at line 415 of file mcxt.c.

References AssertArg, MemoryContextData::firstchild, MemoryContextMethods::is_empty, MemoryContextIsValid, MemoryContextData::methods, and NULL.

Referenced by AtSubCommit_Memory().

416 {
418 
419  /*
420  * For now, we consider a memory context nonempty if it has any children;
421  * perhaps this should be changed later.
422  */
423  if (context->firstchild != NULL)
424  return false;
425  /* Otherwise use the type-specific inquiry */
426  return (*context->methods->is_empty) (context);
427 }
MemoryContextMethods * methods
Definition: memnodes.h:79
bool(* is_empty)(MemoryContext context)
Definition: memnodes.h:64
MemoryContext firstchild
Definition: memnodes.h:81
#define AssertArg(condition)
Definition: c.h:677
#define MemoryContextIsValid(context)
Definition: memnodes.h:97
#define NULL
Definition: c.h:229
void MemoryContextReset ( MemoryContext  context)

Definition at line 135 of file mcxt.c.

References AssertArg, MemoryContextData::firstchild, MemoryContextData::isReset, MemoryContextDeleteChildren(), MemoryContextIsValid, MemoryContextResetOnly(), and NULL.

Referenced by _bt_preprocess_array_keys(), AfterTriggerExecute(), bloomBuildCallback(), brin_memtuple_initialize(), bt_check_level_from_leftmost(), btvacuumpage(), buildSubPlanHash(), CopyOneRowTo(), dumpbatch(), each_object_field_end(), each_worker_jsonb(), elements_array_element_end(), elements_worker_jsonb(), errstart(), EventTriggerInvoke(), exec_dynquery_with_params(), exec_stmt_block(), exec_stmt_dynexecute(), exec_stmt_forc(), exec_stmt_foreach_a(), exec_stmt_open(), exec_stmt_raise(), ExecHashTableReset(), ExecMakeTableFunctionResult(), ExecRecursiveUnion(), execTuplesMatch(), execTuplesUnequal(), fetch_more_data(), file_acquire_sample_rows(), gin_redo(), ginBuildCallback(), ginHeapTupleBulkInsert(), ginInsertCleanup(), ginVacuumPostingTreeLeaves(), gist_redo(), gistBuildCallback(), gistgetbitmap(), gistgettuple(), gistinsert(), gistProcessEmptyingQueue(), gistrescan(), gistScanPage(), HandleParallelMessages(), IndexBuildHeapRangeScan(), IndexCheckExclusion(), keyGetItem(), libpqrcv_processTuples(), make_tuple_from_result_row(), pg_decode_change(), pgoutput_change(), plperl_return_next(), PLyDict_FromTuple(), postgresExecForeignDelete(), postgresExecForeignInsert(), postgresExecForeignUpdate(), printtup(), printtup_20(), printtup_internal_20(), process_ordered_aggregate_multi(), process_ordered_aggregate_single(), ReScanExprContext(), scanPendingInsert(), sepgsql_avc_reset(), setop_fill_hash_table(), spg_redo(), spginsert(), spgistBuildCallback(), spgWalk(), startScanKey(), storeRow(), tfuncLoadRows(), tqueueReceiveSlot(), and validate_index_heapscan().

136 {
138 
139  /* save a function call in common case where there are no children */
140  if (context->firstchild != NULL)
142 
143  /* save a function call if no pallocs since startup or last reset */
144  if (!context->isReset)
145  MemoryContextResetOnly(context);
146 }
void MemoryContextResetOnly(MemoryContext context)
Definition: mcxt.c:154
MemoryContext firstchild
Definition: memnodes.h:81
#define AssertArg(condition)
Definition: c.h:677
void MemoryContextDeleteChildren(MemoryContext context)
Definition: mcxt.c:236
#define MemoryContextIsValid(context)
Definition: memnodes.h:97
#define NULL
Definition: c.h:229
void MemoryContextResetChildren ( MemoryContext  context)

Definition at line 176 of file mcxt.c.

References AssertArg, MemoryContextData::firstchild, MemoryContextIsValid, MemoryContextResetChildren(), MemoryContextResetOnly(), MemoryContextData::nextchild, and NULL.

Referenced by MemoryContextResetChildren().

177 {
178  MemoryContext child;
179 
181 
182  for (child = context->firstchild; child != NULL; child = child->nextchild)
183  {
185  MemoryContextResetOnly(child);
186  }
187 }
void MemoryContextResetOnly(MemoryContext context)
Definition: mcxt.c:154
MemoryContext firstchild
Definition: memnodes.h:81
#define AssertArg(condition)
Definition: c.h:677
#define MemoryContextIsValid(context)
Definition: memnodes.h:97
#define NULL
Definition: c.h:229
void MemoryContextResetChildren(MemoryContext context)
Definition: mcxt.c:176
MemoryContext nextchild
Definition: memnodes.h:83
void MemoryContextResetOnly ( MemoryContext  context)

Definition at line 154 of file mcxt.c.

References AssertArg, MemoryContextData::isReset, MemoryContextCallResetCallbacks(), MemoryContextIsValid, MemoryContextData::methods, MemoryContextMethods::reset, VALGRIND_CREATE_MEMPOOL, and VALGRIND_DESTROY_MEMPOOL.

Referenced by MemoryContextReset(), and MemoryContextResetChildren().

155 {
157 
158  /* Nothing to do if no pallocs since startup or last reset */
159  if (!context->isReset)
160  {
162  (*context->methods->reset) (context);
163  context->isReset = true;
164  VALGRIND_DESTROY_MEMPOOL(context);
165  VALGRIND_CREATE_MEMPOOL(context, 0, false);
166  }
167 }
static void MemoryContextCallResetCallbacks(MemoryContext context)
Definition: mcxt.c:282
MemoryContextMethods * methods
Definition: memnodes.h:79
void(* reset)(MemoryContext context)
Definition: memnodes.h:61
#define AssertArg(condition)
Definition: c.h:677
#define VALGRIND_DESTROY_MEMPOOL(context)
Definition: memdebug.h:25
#define VALGRIND_CREATE_MEMPOOL(context, redzones, zeroed)
Definition: memdebug.h:24
#define MemoryContextIsValid(context)
Definition: memnodes.h:97
void MemoryContextSetParent ( MemoryContext  context,
MemoryContext  new_parent 
)

Definition at line 317 of file mcxt.c.

References Assert, AssertArg, MemoryContextData::firstchild, MemoryContextIsValid, MemoryContextData::nextchild, NULL, MemoryContextData::parent, and MemoryContextData::prevchild.

Referenced by _SPI_save_plan(), CachedPlanSetParentContext(), CompleteCachedPlan(), exec_parse_message(), GetCachedPlan(), load_domaintype_info(), MemoryContextDelete(), RevalidateCachedQuery(), SaveCachedPlan(), SPI_keepplan(), and TransferExpandedObject().

318 {
320  AssertArg(context != new_parent);
321 
322  /* Fast path if it's got correct parent already */
323  if (new_parent == context->parent)
324  return;
325 
326  /* Delink from existing parent, if any */
327  if (context->parent)
328  {
329  MemoryContext parent = context->parent;
330 
331  if (context->prevchild != NULL)
332  context->prevchild->nextchild = context->nextchild;
333  else
334  {
335  Assert(parent->firstchild == context);
336  parent->firstchild = context->nextchild;
337  }
338 
339  if (context->nextchild != NULL)
340  context->nextchild->prevchild = context->prevchild;
341  }
342 
343  /* And relink */
344  if (new_parent)
345  {
346  AssertArg(MemoryContextIsValid(new_parent));
347  context->parent = new_parent;
348  context->prevchild = NULL;
349  context->nextchild = new_parent->firstchild;
350  if (new_parent->firstchild != NULL)
351  new_parent->firstchild->prevchild = context;
352  new_parent->firstchild = context;
353  }
354  else
355  {
356  context->parent = NULL;
357  context->prevchild = NULL;
358  context->nextchild = NULL;
359  }
360 }
MemoryContext firstchild
Definition: memnodes.h:81
MemoryContext prevchild
Definition: memnodes.h:82
#define AssertArg(condition)
Definition: c.h:677
#define MemoryContextIsValid(context)
Definition: memnodes.h:97
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
MemoryContext parent
Definition: memnodes.h:80
MemoryContext nextchild
Definition: memnodes.h:83
void MemoryContextStats ( MemoryContext  context)

Definition at line 438 of file mcxt.c.

References MemoryContextStatsDetail().

Referenced by AllocSetContextCreate(), finish_xact_command(), MemoryContextAlloc(), MemoryContextAllocExtended(), MemoryContextAllocHuge(), MemoryContextAllocZero(), MemoryContextAllocZeroAligned(), palloc(), palloc0(), palloc_extended(), repalloc(), and repalloc_huge().

439 {
440  /* A hard-wired limit on the number of children is usually good enough */
441  MemoryContextStatsDetail(context, 100);
442 }
void MemoryContextStatsDetail(MemoryContext context, int max_children)
Definition: mcxt.c:450
void MemoryContextStatsDetail ( MemoryContext  context,
int  max_children 
)

Definition at line 450 of file mcxt.c.

References MemoryContextCounters::freechunks, MemoryContextCounters::freespace, MemoryContextStatsInternal(), MemoryContextCounters::nblocks, and MemoryContextCounters::totalspace.

Referenced by MemoryContextStats().

451 {
452  MemoryContextCounters grand_totals;
453 
454  memset(&grand_totals, 0, sizeof(grand_totals));
455 
456  MemoryContextStatsInternal(context, 0, true, max_children, &grand_totals);
457 
458  fprintf(stderr,
459  "Grand total: %zu bytes in %zd blocks; %zu free (%zd chunks); %zu used\n",
460  grand_totals.totalspace, grand_totals.nblocks,
461  grand_totals.freespace, grand_totals.freechunks,
462  grand_totals.totalspace - grand_totals.freespace);
463 }
static void MemoryContextStatsInternal(MemoryContext context, int level, bool print, int max_children, MemoryContextCounters *totals)
Definition: mcxt.c:473
MemoryContext SlabContextCreate ( MemoryContext  parent,
const char *  name,
Size  blockSize,
Size  chunkSize 
)

Definition at line 183 of file slab.c.

References Assert, SlabContext::blockSize, SlabContext::chunkSize, SlabContext::chunksPerBlock, elog, ERROR, SlabContext::fullChunkSize, MAXALIGN, MemoryContextCreate(), SlabContext::minFreeChunks, name, SlabContext::nblocks, offsetof, SlabMethods, StaticAssertStmt, and T_SlabContext.

Referenced by ReorderBufferAllocate().

187 {
188  int chunksPerBlock;
189  Size fullChunkSize;
190  Size freelistSize;
191  SlabContext *slab;
192 
194  MAXALIGN(sizeof(SlabChunk)),
195  "padding calculation in SlabChunk is wrong");
196 
197  /* otherwise the linked list inside freed chunk isn't guaranteed to fit */
198  StaticAssertStmt(MAXIMUM_ALIGNOF >= sizeof(int),
199  "MAXALIGN too small to fit int32");
200 
201  /* chunk, including SLAB header (both addresses nicely aligned) */
202  fullChunkSize = MAXALIGN(sizeof(SlabChunk) + MAXALIGN(chunkSize));
203 
204  /* Make sure the block can store at least one chunk. */
205  if (blockSize - sizeof(SlabBlock) < fullChunkSize)
206  elog(ERROR, "block size %zu for slab is too small for %zu chunks",
207  blockSize, chunkSize);
208 
209  /* Compute maximum number of chunks per block */
210  chunksPerBlock = (blockSize - sizeof(SlabBlock)) / fullChunkSize;
211 
212  /* The freelist starts with 0, ends with chunksPerBlock. */
213  freelistSize = sizeof(dlist_head) * (chunksPerBlock + 1);
214 
215  /* if we can't fit at least one chunk into the block, we're hosed */
216  Assert(chunksPerBlock > 0);
217 
218  /* make sure the chunks actually fit on the block */
219  Assert((fullChunkSize * chunksPerBlock) + sizeof(SlabBlock) <= blockSize);
220 
221  /* Do the type-independent part of context creation */
222  slab = (SlabContext *)
224  (offsetof(SlabContext, freelist) +freelistSize),
225  &SlabMethods,
226  parent,
227  name);
228 
229  slab->blockSize = blockSize;
230  slab->chunkSize = chunkSize;
231  slab->fullChunkSize = fullChunkSize;
232  slab->chunksPerBlock = chunksPerBlock;
233  slab->nblocks = 0;
234  slab->minFreeChunks = 0;
235 
236  return (MemoryContext) slab;
237 }
int nblocks
Definition: slab.c:72
Size blockSize
Definition: slab.c:69
struct dlist_head dlist_head
static MemoryContextMethods SlabMethods
Definition: slab.c:137
Size chunkSize
Definition: slab.c:67
#define StaticAssertStmt(condition, errmessage)
Definition: c.h:757
#define ERROR
Definition: elog.h:43
int chunksPerBlock
Definition: slab.c:70
Size fullChunkSize
Definition: slab.c:68
MemoryContext MemoryContextCreate(NodeTag tag, Size size, MemoryContextMethods *methods, MemoryContext parent, const char *name)
Definition: mcxt.c:640
#define Assert(condition)
Definition: c.h:675
struct SlabBlock SlabBlock
size_t Size
Definition: c.h:356
#define MAXALIGN(LEN)
Definition: c.h:588
const char * name
Definition: encode.c:521
Definition: slab.c:85
int minFreeChunks
Definition: slab.c:71
#define elog
Definition: elog.h:219
#define offsetof(type, field)
Definition: c.h:555
Definition: slab.c:96

Variable Documentation

PGDLLIMPORT MemoryContext CacheMemoryContext

Definition at line 46 of file mcxt.c.

Referenced by _SPI_save_plan(), AllocateRelationDesc(), ApplyWorkerMain(), assign_record_type_typmod(), AttrDefaultFetch(), BuildEventTriggerCache(), BuildHardcodedDescriptor(), CatalogCacheCreateEntry(), CatalogCacheInitializeCache(), CheckConstraintFetch(), CreateCacheMemoryContext(), generate_partition_qual(), get_attribute_options(), get_rel_sync_entry(), get_tablespace(), GetCachedPlan(), GetConnection(), GetFdwRoutineForRelation(), GetRelationPublicationActions(), init_ts_config_cache(), InitCatCache(), InitializeAttoptCache(), InitializeRelfilenodeMap(), InitializeTableSpaceCache(), load_domaintype_info(), load_enum_cache_data(), load_rangetype_info(), load_relcache_init_file(), logicalrep_relmap_init(), lookup_ts_config_cache(), lookup_ts_dictionary_cache(), lookup_ts_parser_cache(), lookup_type_cache(), LookupOpclassInfo(), pgoutput_startup(), process_syncing_tables_for_apply(), register_on_commit_action(), RehashCatCache(), RelationBuildLocalRelation(), RelationBuildPartitionDesc(), RelationBuildPartitionKey(), RelationBuildRowSecurity(), RelationBuildRuleLock(), RelationBuildTriggers(), RelationBuildTupleDesc(), RelationCacheInitialize(), RelationCacheInitializePhase2(), RelationCacheInitializePhase3(), RelationGetFKeyList(), RelationGetIndexAttrBitmap(), RelationGetIndexList(), RelationGetStatExtList(), RelationInitIndexAccessInfo(), RelationParseRelOptions(), RelationSetIndexList(), RememberToFreeTupleDescAtEOX(), SaveCachedPlan(), SearchCatCacheList(), and SPI_keepplan().

PGDLLIMPORT MemoryContext TopMemoryContext

Definition at line 43 of file mcxt.c.

Referenced by _PG_init(), add_reloption(), add_string_reloption(), allocate_reloption(), AllocateAttribute(), AllocSetContextCreate(), ApplyLauncherMain(), AtAbort_Memory(), AtCleanup_Memory(), AtCommit_Memory(), AtStart_Memory(), AutoVacLauncherMain(), BackendRun(), BackgroundWriterMain(), be_tls_open_server(), cache_single_time(), CheckpointerMain(), compile_plperl_function(), compile_pltcl_function(), ConditionVariablePrepareToSleep(), ConvertTriggerToFK(), CreateCacheMemoryContext(), dblink_connect(), dblink_init(), do_autovacuum(), do_compile(), do_start_bgworker(), dsm_create_descriptor(), dsm_impl_sysv(), EnablePortalManager(), EventTriggerBeginCompleteQuery(), Exec_ListenCommit(), finish_xact_command(), get_tabstat_entry(), GetLocalBufferStorage(), GetLockConflicts(), HandleParallelMessages(), hash_create(), InitDeadLockChecking(), initialize_reloptions(), InitializeParallelDSM(), InitializeSearchPath(), InitXLogInsert(), LockAcquireExtended(), LogicalRepApplyLoop(), make_sure_stat_tab_initialized(), mdinit(), MemoryContextInit(), mxid_to_string(), on_dsm_detach(), PageSetChecksumCopy(), ParallelWorkerMain(), PerformAuthentication(), pg_start_backup(), pgstat_setup_memcxt(), plperl_spi_prepare(), plpgsql_estate_setup(), plpython_inline_handler(), pltcl_SPI_prepare(), PLy_cursor_plan(), PLy_cursor_query(), PLy_procedure_create(), PLy_spi_execute_fetch_result(), PLy_spi_prepare(), PostgresMain(), PostmasterMain(), pq_init(), PrepareClientEncoding(), ProcessStartupPacket(), PushOverrideSearchPath(), px_find_cipher(), px_find_digest(), recomputeNamespacePath(), register_label_provider(), RegisterLWLockTranches(), RegisterResourceReleaseCallback(), RegisterSubXactCallback(), RegisterXactCallback(), regress_putenv(), RelationCreateStorage(), RelationDropStorage(), RequestNamedLWLockTranche(), ResourceArrayEnlarge(), ResourceOwnerCreate(), ri_HashCompareOp(), roles_has_privs_of(), roles_is_member_of(), sepgsql_avc_init(), sepgsql_xact_callback(), SetDatabasePath(), StartChildProcess(), WalWriterMain(), and XLOGShmemInit().