#include "nodes/memnodes.h"
Go to the source code of this file.
| #define ALLOCSET_DEFAULT_INITSIZE (8 * 1024) |
Definition at line 133 of file memutils.h.
Referenced by accumArrayResult(), afterTriggerAddEvent(), afterTriggerInvokeEvents(), AtStart_Memory(), AtSubStart_Memory(), AutoVacLauncherMain(), BackgroundWriterMain(), begin_heap_rewrite(), BeginCopy(), 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(), EnablePortalManager(), EventTriggerBeginCompleteQuery(), EventTriggerInvoke(), exec_parse_message(), exec_replication_command(), ExecHashTableCreate(), ExecInitAgg(), ExecInitRecursiveUnion(), ExecInitSetOp(), ExecInitSubPlan(), ExecInitUnique(), ExecInitWindowAgg(), file_acquire_sample_rows(), geqo_eval(), GetLocalBufferStorage(), gin_xlog_startup(), ginbeginscan(), ginbuild(), gininsert(), ginInsertCleanup(), gistrescan(), hash_create(), index_register(), init_sql_fcache(), initGISTstate(), inline_function(), inline_set_returning_function(), json_array_elements(), mdinit(), NIStartBuild(), plperl_return_next(), plperl_spi_prepare(), plpgsql_compile_inline(), PLy_push_execution_context(), PortalCreateHoldStore(), postgresBeginForeignScan(), PostgresMain(), PostmasterMain(), rebuild_database_list(), ReindexDatabase(), ResetUnloggedRelations(), sepgsql_avc_init(), spg_xlog_startup(), spgbeginscan(), spgbuild(), spginsert(), SPI_connect(), spi_dest_startup(), storeRow(), tokenize_file(), tuplesort_begin_common(), vacuum(), and WalWriterMain().
| #define ALLOCSET_DEFAULT_MAXSIZE (8 * 1024 * 1024) |
Definition at line 134 of file memutils.h.
Referenced by accumArrayResult(), afterTriggerAddEvent(), afterTriggerInvokeEvents(), AtStart_Memory(), AtSubStart_Memory(), AutoVacLauncherMain(), BackgroundWriterMain(), begin_heap_rewrite(), BeginCopy(), btvacuumscan(), BuildCachedPlan(), BuildEventTriggerCache(), CheckpointerMain(), cluster(), CompleteCachedPlan(), compute_index_stats(), CopyCachedPlan(), CopyTo(), CreateCachedPlan(), CreateCacheMemoryContext(), CreateExecutorState(), CreateExprContext(), CreateStandaloneExprContext(), createTempGistContext(), createTrgmNFA(), do_analyze_rel(), do_autovacuum(), do_compile(), do_start_worker(), each_worker(), EnablePortalManager(), EventTriggerBeginCompleteQuery(), EventTriggerInvoke(), exec_parse_message(), exec_replication_command(), ExecHashTableCreate(), ExecInitAgg(), ExecInitRecursiveUnion(), ExecInitSetOp(), ExecInitSubPlan(), ExecInitUnique(), ExecInitWindowAgg(), file_acquire_sample_rows(), geqo_eval(), GetLocalBufferStorage(), gin_xlog_startup(), ginbeginscan(), ginbuild(), gininsert(), ginInsertCleanup(), gistrescan(), hash_create(), index_register(), init_sql_fcache(), initGISTstate(), inline_function(), inline_set_returning_function(), json_array_elements(), load_hba(), load_ident(), mdinit(), NIStartBuild(), plperl_return_next(), plperl_spi_prepare(), plpgsql_compile_inline(), PLy_push_execution_context(), PortalCreateHoldStore(), postgresBeginForeignScan(), PostgresMain(), PostmasterMain(), rebuild_database_list(), ReindexDatabase(), ResetUnloggedRelations(), RevalidateCachedQuery(), sepgsql_avc_init(), spg_xlog_startup(), spgbeginscan(), spgbuild(), spginsert(), SPI_connect(), spi_dest_startup(), storeRow(), tokenize_file(), tuplesort_begin_common(), vacuum(), and WalWriterMain().
| #define ALLOCSET_DEFAULT_MINSIZE 0 |
Definition at line 132 of file memutils.h.
Referenced by accumArrayResult(), afterTriggerAddEvent(), afterTriggerInvokeEvents(), AtStart_Memory(), AtSubStart_Memory(), AutoVacLauncherMain(), BackgroundWriterMain(), begin_heap_rewrite(), BeginCopy(), 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(), EnablePortalManager(), EventTriggerBeginCompleteQuery(), EventTriggerInvoke(), exec_parse_message(), exec_replication_command(), ExecHashTableCreate(), ExecInitAgg(), ExecInitRecursiveUnion(), ExecInitSetOp(), ExecInitSubPlan(), ExecInitUnique(), ExecInitWindowAgg(), file_acquire_sample_rows(), geqo_eval(), GetLocalBufferStorage(), gin_xlog_startup(), ginbeginscan(), ginbuild(), gininsert(), ginInsertCleanup(), gistrescan(), hash_create(), index_register(), init_sql_fcache(), initGISTstate(), inline_function(), inline_set_returning_function(), json_array_elements(), load_hba(), load_ident(), mdinit(), NIStartBuild(), plperl_return_next(), plperl_spi_prepare(), plpgsql_compile_inline(), PLy_push_execution_context(), PortalCreateHoldStore(), postgresBeginForeignScan(), PostgresMain(), PostmasterMain(), rebuild_database_list(), ReindexDatabase(), ResetUnloggedRelations(), sepgsql_avc_init(), spg_xlog_startup(), spgbeginscan(), spgbuild(), spginsert(), SPI_connect(), spi_dest_startup(), storeRow(), tokenize_file(), tuplesort_begin_common(), vacuum(), and WalWriterMain().
| #define ALLOCSET_SMALL_INITSIZE (1 * 1024) |
Definition at line 141 of file memutils.h.
Referenced by _bt_preprocess_array_keys(), _SPI_make_plan_non_temp(), _SPI_save_plan(), BuildCachedPlan(), CompleteCachedPlan(), CopyCachedPlan(), CreateCachedPlan(), CreatePortal(), ExecInitSubPlan(), init_MultiFuncCall(), load_relcache_init_file(), load_tzoffsets(), lookup_ts_dictionary_cache(), mXactCachePut(), pgstat_setup_memcxt(), plperl_spi_prepare(), postgresAcquireSampleRowsFunc(), postgresBeginForeignModify(), postgresBeginForeignScan(), RelationBuildRuleLock(), RelationInitIndexAccessInfo(), and RevalidateCachedQuery().
| #define ALLOCSET_SMALL_MAXSIZE (8 * 1024) |
Definition at line 142 of file memutils.h.
Referenced by _bt_preprocess_array_keys(), _SPI_make_plan_non_temp(), _SPI_save_plan(), CreatePortal(), ExecInitSubPlan(), init_MultiFuncCall(), load_relcache_init_file(), load_tzoffsets(), lookup_ts_dictionary_cache(), mXactCachePut(), pgstat_setup_memcxt(), plperl_spi_prepare(), postgresAcquireSampleRowsFunc(), postgresBeginForeignModify(), postgresBeginForeignScan(), RelationBuildRuleLock(), and RelationInitIndexAccessInfo().
| #define ALLOCSET_SMALL_MINSIZE 0 |
Definition at line 140 of file memutils.h.
Referenced by _bt_preprocess_array_keys(), _SPI_make_plan_non_temp(), _SPI_save_plan(), BuildCachedPlan(), CompleteCachedPlan(), CopyCachedPlan(), CreateCachedPlan(), CreatePortal(), ExecInitSubPlan(), init_MultiFuncCall(), load_relcache_init_file(), load_tzoffsets(), lookup_ts_dictionary_cache(), mXactCachePut(), pgstat_setup_memcxt(), plperl_spi_prepare(), postgresAcquireSampleRowsFunc(), postgresBeginForeignModify(), postgresBeginForeignScan(), RelationBuildRuleLock(), RelationInitIndexAccessInfo(), and RevalidateCachedQuery().
| #define AllocSizeIsValid | ( | size | ) | ((Size) (size) <= MaxAllocSize) |
Definition at line 42 of file memutils.h.
Referenced by array_fill_internal(), array_map(), array_replace_internal(), construct_md_array(), MemoryContextAlloc(), MemoryContextAllocZero(), MemoryContextAllocZeroAligned(), MemoryContextContains(), palloc(), palloc0(), ReadArrayBinary(), ReadArrayStr(), and repalloc().
| #define MaxAllocSize ((Size) 0x3fffffff) |
Definition at line 40 of file memutils.h.
Referenced by array_fill_internal(), array_map(), array_replace_internal(), AtSubCommit_childXids(), construct_md_array(), EndPrepare(), enlargeStringInfo(), ExecHashIncreaseNumBatches(), GetLocalBufferStorage(), grow_memtuples(), lazy_space_alloc(), perform_default_encoding_conversion(), pg_do_encoding_conversion(), read_binary_file(), ReadArrayBinary(), ReadArrayStr(), ReadTwoPhaseFile(), tsqueryrecv(), and tsvectorrecv().
| #define STANDARDCHUNKHEADERSIZE MAXALIGN(sizeof(StandardChunkHeader)) |
Definition at line 63 of file memutils.h.
| typedef struct StandardChunkHeader StandardChunkHeader |
| MemoryContext AllocSetContextCreate | ( | MemoryContext | parent, | |
| const char * | name, | |||
| Size | minContextSize, | |||
| Size | initBlockSize, | |||
| Size | maxBlockSize | |||
| ) |
Definition at line 353 of file aset.c.
References ALLOC_BLOCKHDRSZ, ALLOC_CHUNK_FRACTION, ALLOC_CHUNKHDRSZ, AllocSetContext::allocChunkLimit, AllocBlockData::aset, AllocSetContext::blocks, AllocBlockData::endptr, ereport, errcode(), errdetail(), errmsg(), ERROR, AllocBlockData::freeptr, AllocSetContext::initBlockSize, AllocSetContext::keeper, malloc, MAXALIGN, AllocSetContext::maxBlockSize, MemoryContextCreate(), MemoryContextStats(), AllocBlockData::next, AllocSetContext::nextBlockSize, NULL, T_AllocSetContext, and TopMemoryContext.
Referenced by _bt_preprocess_array_keys(), _SPI_make_plan_non_temp(), _SPI_save_plan(), accumArrayResult(), afterTriggerAddEvent(), afterTriggerInvokeEvents(), AtStart_Memory(), AtSubStart_Memory(), AutoVacLauncherMain(), BackgroundWriterMain(), begin_heap_rewrite(), BeginCopy(), btvacuumscan(), BuildCachedPlan(), BuildEventTriggerCache(), CheckpointerMain(), cluster(), CompleteCachedPlan(), compute_index_stats(), CopyCachedPlan(), CopyTo(), CreateCachedPlan(), CreateCacheMemoryContext(), CreateExecutorState(), CreateExprContext(), CreatePortal(), CreateStandaloneExprContext(), createTempGistContext(), createTrgmNFA(), do_analyze_rel(), do_autovacuum(), do_compile(), do_start_worker(), each_worker(), EnablePortalManager(), EventTriggerBeginCompleteQuery(), EventTriggerInvoke(), exec_parse_message(), exec_replication_command(), ExecHashTableCreate(), ExecInitAgg(), ExecInitRecursiveUnion(), ExecInitSetOp(), ExecInitSubPlan(), ExecInitUnique(), ExecInitWindowAgg(), file_acquire_sample_rows(), geqo_eval(), GetLocalBufferStorage(), gin_xlog_startup(), ginbeginscan(), ginbuild(), gininsert(), ginInsertCleanup(), gistrescan(), hash_create(), index_register(), init_MultiFuncCall(), init_sql_fcache(), initGISTstate(), inline_function(), inline_set_returning_function(), json_array_elements(), load_hba(), load_ident(), load_relcache_init_file(), load_tzoffsets(), lookup_ts_dictionary_cache(), mdinit(), MemoryContextInit(), mXactCachePut(), NIStartBuild(), pgstat_setup_memcxt(), plperl_return_next(), plperl_spi_prepare(), plpgsql_compile_inline(), PLy_push_execution_context(), PortalCreateHoldStore(), postgresAcquireSampleRowsFunc(), postgresBeginForeignModify(), postgresBeginForeignScan(), PostgresMain(), PostmasterMain(), rebuild_database_list(), ReindexDatabase(), RelationBuildRuleLock(), RelationInitIndexAccessInfo(), ResetUnloggedRelations(), RevalidateCachedQuery(), sepgsql_avc_init(), spg_xlog_startup(), spgbeginscan(), spgbuild(), spginsert(), SPI_connect(), spi_dest_startup(), storeRow(), tokenize_file(), tuplesort_begin_common(), vacuum(), and WalWriterMain().
{
AllocSet context;
/* Do the type-independent part of context creation */
context = (AllocSet) MemoryContextCreate(T_AllocSetContext,
sizeof(AllocSetContext),
&AllocSetMethods,
parent,
name);
/*
* Make sure alloc parameters are reasonable, and save them.
*
* We somewhat arbitrarily enforce a minimum 1K block size.
*/
initBlockSize = MAXALIGN(initBlockSize);
if (initBlockSize < 1024)
initBlockSize = 1024;
maxBlockSize = MAXALIGN(maxBlockSize);
if (maxBlockSize < initBlockSize)
maxBlockSize = initBlockSize;
context->initBlockSize = initBlockSize;
context->maxBlockSize = maxBlockSize;
context->nextBlockSize = initBlockSize;
/*
* Compute the allocation chunk size limit for this context. It can't be
* more than ALLOC_CHUNK_LIMIT because of the fixed number of freelists.
* If maxBlockSize is small then requests exceeding the maxBlockSize, or
* even a significant fraction of it, should be treated as large chunks
* too. For the typical case of maxBlockSize a power of 2, the chunk size
* limit will be at most 1/8th maxBlockSize, so that given a stream of
* requests that are all the maximum chunk size we will waste at most
* 1/8th of the allocated space.
*
* We have to have allocChunkLimit a power of two, because the requested
* and actually-allocated sizes of any chunk must be on the same side of
* the limit, else we get confused about whether the chunk is "big".
*/
context->allocChunkLimit = ALLOC_CHUNK_LIMIT;
while ((Size) (context->allocChunkLimit + ALLOC_CHUNKHDRSZ) >
(Size) ((maxBlockSize - ALLOC_BLOCKHDRSZ) / ALLOC_CHUNK_FRACTION))
context->allocChunkLimit >>= 1;
/*
* Grab always-allocated space, if requested
*/
if (minContextSize > ALLOC_BLOCKHDRSZ + ALLOC_CHUNKHDRSZ)
{
Size blksize = MAXALIGN(minContextSize);
AllocBlock block;
block = (AllocBlock) malloc(blksize);
if (block == NULL)
{
MemoryContextStats(TopMemoryContext);
ereport(ERROR,
(errcode(ERRCODE_OUT_OF_MEMORY),
errmsg("out of memory"),
errdetail("Failed while creating memory context \"%s\".",
name)));
}
block->aset = context;
block->freeptr = ((char *) block) + ALLOC_BLOCKHDRSZ;
block->endptr = ((char *) block) + blksize;
block->next = context->blocks;
context->blocks = block;
/* Mark block as not to be released at reset time */
context->keeper = block;
}
return (MemoryContext) context;
}
| MemoryContext GetMemoryChunkContext | ( | void * | pointer | ) |
Definition at line 325 of file mcxt.c.
References Assert, AssertArg, StandardChunkHeader::context, MAXALIGN, MemoryContextIsValid, and NULL.
Referenced by mark_dummy_rel().
{
StandardChunkHeader *header;
/*
* Try to detect bogus pointers handed to us, poorly though we can.
* Presumably, a pointer that isn't MAXALIGNED isn't pointing at an
* allocated chunk.
*/
Assert(pointer != NULL);
Assert(pointer == (void *) MAXALIGN(pointer));
/*
* OK, it's probably safe to look at the chunk header.
*/
header = (StandardChunkHeader *)
((char *) pointer - STANDARDCHUNKHEADERSIZE);
AssertArg(MemoryContextIsValid(header->context));
return header->context;
}
| Size GetMemoryChunkSpace | ( | void * | pointer | ) |
Definition at line 295 of file mcxt.c.
References Assert, AssertArg, StandardChunkHeader::context, MemoryContextMethods::get_chunk_space, MAXALIGN, MemoryContextIsValid, MemoryContextData::methods, and NULL.
Referenced by copytup_cluster(), copytup_heap(), copytup_index(), free_sort_tuple(), getDatumCopy(), ginAllocEntryAccumulator(), ginCombineData(), ginInsertBAEntry(), grow_memtuples(), inittapes(), readtup_cluster(), readtup_datum(), readtup_heap(), readtup_index(), tuplesort_begin_common(), tuplesort_gettuple_common(), tuplesort_putdatum(), tuplestore_begin_common(), tuplestore_clear(), tuplestore_puttupleslot(), tuplestore_putvalues(), tuplestore_trim(), writetup_cluster(), writetup_datum(), writetup_heap(), and writetup_index().
{
StandardChunkHeader *header;
/*
* Try to detect bogus pointers handed to us, poorly though we can.
* Presumably, a pointer that isn't MAXALIGNED isn't pointing at an
* allocated chunk.
*/
Assert(pointer != NULL);
Assert(pointer == (void *) MAXALIGN(pointer));
/*
* OK, it's probably safe to look at the chunk header.
*/
header = (StandardChunkHeader *)
((char *) pointer - STANDARDCHUNKHEADERSIZE);
AssertArg(MemoryContextIsValid(header->context));
return (*header->context->methods->get_chunk_space) (header->context,
pointer);
}
| bool MemoryContextContains | ( | MemoryContext | context, | |
| void * | pointer | |||
| ) |
Definition at line 436 of file mcxt.c.
References AllocSizeIsValid, StandardChunkHeader::context, MAXALIGN, NULL, and StandardChunkHeader::size.
Referenced by eval_windowfunction(), finalize_aggregate(), and finalize_windowaggregate().
{
StandardChunkHeader *header;
/*
* Try to detect bogus pointers handed to us, poorly though we can.
* Presumably, a pointer that isn't MAXALIGNED isn't pointing at an
* allocated chunk.
*/
if (pointer == NULL || pointer != (void *) MAXALIGN(pointer))
return false;
/*
* OK, it's probably safe to look at the chunk header.
*/
header = (StandardChunkHeader *)
((char *) pointer - STANDARDCHUNKHEADERSIZE);
/*
* If the context link doesn't match then we certainly have a non-member
* chunk. Also check for a reasonable-looking size as extra guard against
* being fooled by bogus pointers.
*/
if (header->context == context && AllocSizeIsValid(header->size))
return true;
return false;
}
| MemoryContext MemoryContextCreate | ( | NodeTag | tag, | |
| Size | size, | |||
| MemoryContextMethods * | methods, | |||
| MemoryContext | parent, | |||
| const char * | name | |||
| ) |
Definition at line 513 of file mcxt.c.
References Assert, MemoryContextData::firstchild, MemoryContextMethods::init, MemoryContextData::isReset, malloc, MemoryContextAlloc(), MemSet, MemoryContextData::methods, MemoryContextData::name, MemoryContextData::nextchild, NULL, MemoryContextData::parent, and MemoryContextData::type.
Referenced by AllocSetContextCreate().
{
MemoryContext node;
Size needed = size + strlen(name) + 1;
/* Get space for node and name */
if (TopMemoryContext != NULL)
{
/* Normal case: allocate the node in TopMemoryContext */
node = (MemoryContext) MemoryContextAlloc(TopMemoryContext,
needed);
}
else
{
/* Special case for startup: use good ol' malloc */
node = (MemoryContext) malloc(needed);
Assert(node != NULL);
}
/* Initialize the node as best we can */
MemSet(node, 0, size);
node->type = tag;
node->methods = methods;
node->parent = NULL; /* for the moment */
node->firstchild = NULL;
node->nextchild = NULL;
node->isReset = true;
node->name = ((char *) node) + size;
strcpy(node->name, name);
/* Type-specific routine finishes any other essential initialization */
(*node->methods->init) (node);
/* OK to link node to parent (if any) */
/* Could use MemoryContextSetParent here, but doesn't seem worthwhile */
if (parent)
{
node->parent = parent;
node->nextchild = parent->firstchild;
parent->firstchild = node;
}
/* Return to type-specific creation routine to finish up */
return node;
}
| void MemoryContextDelete | ( | MemoryContext | context | ) |
Definition at line 169 of file mcxt.c.
References Assert, AssertArg, MemoryContextMethods::delete_context, MemoryContextDeleteChildren(), MemoryContextIsValid, MemoryContextSetParent(), MemoryContextData::methods, NULL, and pfree().
Referenced by AfterTriggerEndXact(), afterTriggerInvokeEvents(), AtCleanup_Memory(), AtCommit_Memory(), AtEOSubXact_SPI(), AtEOXact_LargeObject(), AtSubCleanup_Memory(), AtSubCommit_Memory(), btendscan(), btvacuumscan(), cluster(), compute_index_stats(), CopyTo(), createTrgmNFA(), do_analyze_rel(), do_start_worker(), DropCachedPlan(), end_heap_rewrite(), EndCopy(), EventTriggerEndCompleteQuery(), EventTriggerInvoke(), exec_replication_command(), ExecEndAgg(), ExecEndRecursiveUnion(), ExecEndSetOp(), ExecEndUnique(), ExecEndWindowAgg(), ExecHashTableDestroy(), file_acquire_sample_rows(), fmgr_sql(), FreeExecutorState(), FreeExprContext(), freeGISTstate(), geqo_eval(), gin_xlog_cleanup(), ginbuild(), ginendscan(), gininsert(), ginInsertCleanup(), gist_xlog_cleanup(), gistbuild(), hash_destroy(), inline_function(), inline_set_returning_function(), load_hba(), load_ident(), load_tzoffsets(), makeMdArrayResult(), MemoryContextDeleteChildren(), NIFinishBuild(), pgstat_clear_snapshot(), plperl_spi_freeplan(), plperl_spi_prepare(), plpgsql_free_function_memory(), PLy_pop_execution_context(), PortalDrop(), PostgresMain(), rebuild_database_list(), ReindexDatabase(), RelationBuildRuleLock(), RelationDestroyRelation(), ReleaseCachedPlan(), ResetUnloggedRelations(), RevalidateCachedQuery(), shutdown_MultiFuncCall(), spg_xlog_cleanup(), spgbuild(), spgendscan(), spginsert(), SPI_finish(), SPI_freeplan(), SPI_freetuptable(), StartChildProcess(), tokenize_inc_file(), tuplesort_end(), and vacuum().
{
AssertArg(MemoryContextIsValid(context));
/* We had better not be deleting TopMemoryContext ... */
Assert(context != TopMemoryContext);
/* And not CurrentMemoryContext, either */
Assert(context != CurrentMemoryContext);
MemoryContextDeleteChildren(context);
/*
* We delink the context from its parent before deleting it, so that if
* there's an error we won't have deleted/busted contexts still attached
* to the context tree. Better a leak than a crash.
*/
MemoryContextSetParent(context, NULL);
(*context->methods->delete_context) (context);
pfree(context);
}
| void MemoryContextDeleteChildren | ( | MemoryContext | context | ) |
Definition at line 196 of file mcxt.c.
References AssertArg, MemoryContextData::firstchild, MemoryContextDelete(), MemoryContextIsValid, and NULL.
Referenced by AtAbort_Portals(), AtSubAbort_Portals(), MemoryContextDelete(), MemoryContextResetAndDeleteChildren(), PersistHoldablePortal(), and PortalRunMulti().
{
AssertArg(MemoryContextIsValid(context));
/*
* MemoryContextDelete will delink the child from me, so just iterate as
* long as there is a child.
*/
while (context->firstchild != NULL)
MemoryContextDelete(context->firstchild);
}
| MemoryContext MemoryContextGetParent | ( | MemoryContext | context | ) |
Definition at line 353 of file mcxt.c.
References AssertArg, MemoryContextIsValid, and MemoryContextData::parent.
Referenced by GetCachedPlan().
{
AssertArg(MemoryContextIsValid(context));
return context->parent;
}
| void MemoryContextInit | ( | void | ) |
Definition at line 79 of file mcxt.c.
References AllocSetContextCreate(), AssertState, and NULL.
Referenced by AuxiliaryProcessMain(), PostgresMain(), and PostmasterMain().
{
AssertState(TopMemoryContext == NULL);
/*
* Initialize TopMemoryContext as an AllocSetContext with slow growth rate
* --- we don't really expect much to be allocated in it.
*
* (There is special-case code in MemoryContextCreate() for this call.)
*/
TopMemoryContext = AllocSetContextCreate((MemoryContext) NULL,
"TopMemoryContext",
0,
8 * 1024,
8 * 1024);
/*
* Not having any other place to point CurrentMemoryContext, make it point
* to TopMemoryContext. Caller should change this soon!
*/
CurrentMemoryContext = TopMemoryContext;
/*
* Initialize ErrorContext as an AllocSetContext with slow growth rate ---
* we don't really expect much to be allocated in it. More to the point,
* require it to contain at least 8K at all times. This is the only case
* where retained memory in a context is *essential* --- we want to be
* sure ErrorContext still has some memory even if we've run out
* elsewhere!
*/
ErrorContext = AllocSetContextCreate(TopMemoryContext,
"ErrorContext",
8 * 1024,
8 * 1024,
8 * 1024);
}
| bool MemoryContextIsEmpty | ( | MemoryContext | context | ) |
Definition at line 365 of file mcxt.c.
References AssertArg, MemoryContextData::firstchild, MemoryContextMethods::is_empty, MemoryContextIsValid, MemoryContextData::methods, and NULL.
Referenced by AtSubCommit_Memory().
{
AssertArg(MemoryContextIsValid(context));
/*
* For now, we consider a memory context nonempty if it has any children;
* perhaps this should be changed later.
*/
if (context->firstchild != NULL)
return false;
/* Otherwise use the type-specific inquiry */
return (*context->methods->is_empty) (context);
}
| void MemoryContextReset | ( | MemoryContext | context | ) |
Definition at line 125 of file mcxt.c.
References AssertArg, MemoryContextData::firstchild, MemoryContextData::isReset, MemoryContextIsValid, MemoryContextResetChildren(), MemoryContextData::methods, NULL, and MemoryContextMethods::reset.
Referenced by _bt_preprocess_array_keys(), AfterTriggerExecute(), btvacuumpage(), buildSubPlanHash(), CopyOneRowTo(), each_object_field_end(), elements_array_element_end(), errstart(), EventTriggerInvoke(), ExecHashTableReset(), ExecRecursiveUnion(), execTuplesMatch(), execTuplesUnequal(), fetch_more_data(), file_acquire_sample_rows(), gin_redo(), gin_xlog_cleanup(), ginBuildCallback(), ginHeapTupleBulkInsert(), ginInsertCleanup(), gist_redo(), gistBuildCallback(), gistProcessEmptyingQueue(), gistrescan(), gistScanPage(), IndexBuildHeapScan(), IndexCheckExclusion(), keyGetItem(), load_hba(), load_ident(), make_tuple_from_result_row(), MemoryContextResetAndDeleteChildren(), MemoryContextResetChildren(), plperl_return_next(), PLyDict_FromTuple(), postgresExecForeignDelete(), postgresExecForeignInsert(), postgresExecForeignUpdate(), process_ordered_aggregate_multi(), process_ordered_aggregate_single(), ReScanExprContext(), scanPendingInsert(), sepgsql_avc_reset(), setop_fill_hash_table(), spg_redo(), spgistBuildCallback(), spgWalk(), storeRow(), and validate_index_heapscan().
{
AssertArg(MemoryContextIsValid(context));
/* save a function call in common case where there are no children */
if (context->firstchild != NULL)
MemoryContextResetChildren(context);
/* Nothing to do if no pallocs since startup or last reset */
if (!context->isReset)
{
(*context->methods->reset) (context);
context->isReset = true;
}
}
| void MemoryContextResetAndDeleteChildren | ( | MemoryContext | context | ) |
Definition at line 217 of file mcxt.c.
References AssertArg, MemoryContextDeleteChildren(), MemoryContextIsValid, and MemoryContextReset().
Referenced by _SPI_end_call(), agg_retrieve_direct(), AtCleanup_Memory(), AtEOSubXact_SPI(), AtSubCleanup_Memory(), AutoVacLauncherMain(), BackgroundWriterMain(), BuildEventTriggerCache(), CheckpointerMain(), compute_index_stats(), do_analyze_rel(), do_autovacuum(), eval_windowaggregates(), ExecReScanAgg(), ExecReScanRecursiveUnion(), ExecReScanSetOp(), FlushErrorState(), InvalidateEventCacheCallback(), lookup_ts_dictionary_cache(), PostgresMain(), release_partition(), and WalWriterMain().
{
AssertArg(MemoryContextIsValid(context));
MemoryContextDeleteChildren(context);
MemoryContextReset(context);
}
| void MemoryContextResetChildren | ( | MemoryContext | context | ) |
Definition at line 148 of file mcxt.c.
References AssertArg, MemoryContextData::firstchild, MemoryContextIsValid, MemoryContextReset(), MemoryContextData::nextchild, and NULL.
Referenced by MemoryContextReset().
{
MemoryContext child;
AssertArg(MemoryContextIsValid(context));
for (child = context->firstchild; child != NULL; child = child->nextchild)
MemoryContextReset(child);
}
| void MemoryContextSetParent | ( | MemoryContext | context, | |
| MemoryContext | new_parent | |||
| ) |
Definition at line 244 of file mcxt.c.
References AssertArg, MemoryContextData::firstchild, MemoryContextIsValid, MemoryContextData::nextchild, and MemoryContextData::parent.
Referenced by _SPI_save_plan(), CachedPlanSetParentContext(), CompleteCachedPlan(), exec_parse_message(), GetCachedPlan(), MemoryContextDelete(), RevalidateCachedQuery(), SaveCachedPlan(), and SPI_keepplan().
{
AssertArg(MemoryContextIsValid(context));
AssertArg(context != new_parent);
/* Delink from existing parent, if any */
if (context->parent)
{
MemoryContext parent = context->parent;
if (context == parent->firstchild)
parent->firstchild = context->nextchild;
else
{
MemoryContext child;
for (child = parent->firstchild; child; child = child->nextchild)
{
if (context == child->nextchild)
{
child->nextchild = context->nextchild;
break;
}
}
}
}
/* And relink */
if (new_parent)
{
AssertArg(MemoryContextIsValid(new_parent));
context->parent = new_parent;
context->nextchild = new_parent->firstchild;
new_parent->firstchild = context;
}
else
{
context->parent = NULL;
context->nextchild = NULL;
}
}
| void MemoryContextStats | ( | MemoryContext | context | ) |
Definition at line 387 of file mcxt.c.
References MemoryContextStatsInternal().
Referenced by AllocSetAlloc(), AllocSetContextCreate(), AllocSetRealloc(), and finish_xact_command().
{
MemoryContextStatsInternal(context, 0);
}
| PGDLLIMPORT MemoryContext CacheMemoryContext |
Definition at line 47 of file mcxt.c.
Referenced by _SPI_save_plan(), AllocateRelationDesc(), assign_record_type_typmod(), AttrDefaultFetch(), BuildEventTriggerCache(), BuildHardcodedDescriptor(), CatalogCacheCreateEntry(), CatalogCacheInitializeCache(), CheckConstraintFetch(), CreateCacheMemoryContext(), get_attribute_options(), get_tablespace(), GetCachedPlan(), GetConnection(), GetFdwRoutineForRelation(), init_ts_config_cache(), InitCatCache(), InitializeAttoptCache(), InitializeTableSpaceCache(), load_enum_cache_data(), load_rangetype_info(), load_relcache_init_file(), lookup_ts_config_cache(), lookup_ts_dictionary_cache(), lookup_ts_parser_cache(), lookup_type_cache(), LookupOpclassInfo(), register_on_commit_action(), RelationBuildLocalRelation(), RelationBuildRuleLock(), RelationBuildTriggers(), RelationBuildTupleDesc(), RelationCacheInitialize(), RelationCacheInitializePhase2(), RelationCacheInitializePhase3(), RelationGetIndexAttrBitmap(), RelationGetIndexList(), RelationInitIndexAccessInfo(), RelationParseRelOptions(), RelationSetIndexList(), SaveCachedPlan(), SearchCatCacheList(), SPI_keepplan(), and write_relcache_init_file().
| PGDLLIMPORT MemoryContext CurTransactionContext |
Definition at line 50 of file mcxt.c.
Referenced by AddInvalidationMessage(), Async_Notify(), AtCleanup_Memory(), AtCommit_Memory(), AtStart_Memory(), AtSubCleanup_Memory(), AtSubCommit_Memory(), AtSubStart_Memory(), NIStartBuild(), PopTransaction(), queue_listen(), ReleaseCurrentSubTransaction(), sepgsql_set_client_label(), StartTransactionCommand(), and xactGetCommittedInvalidationMessages().
| PGDLLIMPORT MemoryContext ErrorContext |
Definition at line 45 of file mcxt.c.
Referenced by CopyErrorData(), elog_finish(), EmitErrorReport(), errcontext_msg(), errdetail(), errdetail_internal(), errdetail_log(), errdetail_plural(), errfinish(), errhint(), errmsg(), errmsg_internal(), errmsg_plural(), errstart(), FlushErrorState(), format_elog_string(), internalerrquery(), ReThrowError(), and set_errdata_field().
| PGDLLIMPORT MemoryContext MessageContext |
Definition at line 48 of file mcxt.c.
Referenced by errdetail_params(), exec_bind_message(), exec_describe_portal_message(), exec_describe_statement_message(), exec_parse_message(), exec_simple_query(), and PostgresMain().
| PGDLLIMPORT MemoryContext PortalContext |
Definition at line 53 of file mcxt.c.
Referenced by cluster(), do_autovacuum(), PersistHoldablePortal(), PortalRun(), PortalRunFetch(), PortalStart(), ReindexDatabase(), and vacuum().
| PGDLLIMPORT MemoryContext PostmasterContext |
Definition at line 46 of file mcxt.c.
Referenced by PostgresMain(), PostmasterMain(), and StartChildProcess().
| PGDLLIMPORT MemoryContext TopMemoryContext |
Definition at line 44 of file mcxt.c.
Referenced by _hash_regscan(), add_reloption(), add_string_reloption(), allocate_reloption(), AllocSetAlloc(), AllocSetContextCreate(), AllocSetRealloc(), AtAbort_Memory(), AtCleanup_Memory(), AtCommit_Memory(), AtStart_Memory(), AutoVacLauncherMain(), BackendRun(), BackgroundWriterMain(), cache_locale_time(), CheckpointerMain(), ConvertTriggerToFK(), CreateCacheMemoryContext(), dblink_connect(), do_autovacuum(), do_compile(), EnablePortalManager(), EventTriggerBeginCompleteQuery(), Exec_ListenCommit(), finish_xact_command(), get_tabstat_entry(), GetLocalBufferStorage(), GetLockConflicts(), hash_create(), InitDeadLockChecking(), initialize_reloptions(), InitializeSearchPath(), load_hba(), load_ident(), LockAcquireExtended(), mdinit(), mxid_to_string(), perm_fmgr_info(), pgstat_setup_memcxt(), plperl_spi_prepare(), PLy_malloc(), PLy_spi_execute_fetch_result(), PostgresMain(), PostmasterMain(), pq_init(), PrepareClientEncoding(), ProcessStartupPacket(), PushOverrideSearchPath(), recomputeNamespacePath(), register_label_provider(), RegisterResourceReleaseCallback(), RegisterSubXactCallback(), RegisterXactCallback(), RelationCreateStorage(), RelationDropStorage(), ResourceOwnerCreate(), ResourceOwnerEnlargeBuffers(), ResourceOwnerEnlargeCatCacheListRefs(), ResourceOwnerEnlargeCatCacheRefs(), ResourceOwnerEnlargeFiles(), ResourceOwnerEnlargePlanCacheRefs(), ResourceOwnerEnlargeRelationRefs(), ResourceOwnerEnlargeSnapshots(), ResourceOwnerEnlargeTupleDescs(), ri_HashCompareOp(), roles_has_privs_of(), roles_is_member_of(), sepgsql_avc_init(), sepgsql_xact_callback(), SetDatabasePath(), StartChildProcess(), tokenize_file(), and WalWriterMain().
| PGDLLIMPORT MemoryContext TopTransactionContext |
Definition at line 49 of file mcxt.c.
Referenced by add_tabstat_xact_level(), afterTriggerAddEvent(), AfterTriggerBeginSubXact(), AfterTriggerBeginXact(), AtCleanup_Memory(), AtCommit_Memory(), AtStart_Inval(), AtStart_Memory(), AtSubCommit_childXids(), AtSubStart_Inval(), AtSubStart_Notify(), BeginInternalSubTransaction(), CopySnapshot(), DefineSavepoint(), do_autovacuum(), ExportSnapshot(), get_tabstat_stack_level(), GetComboCommandId(), mXactCachePut(), plpgsql_create_econtext(), PLy_push_execution_context(), PortalRun(), PrepareTempTablespaces(), PrepareTransactionBlock(), push_old_value(), PushActiveSnapshot(), PushTransaction(), SetConstraintStateCreate(), and SPI_connect().
1.7.1