mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Tweak default memory context allocation policy so that a context is not
given any malloc block until something is first allocated in it; but thereafter, MemoryContextReset won't release that first malloc block. This preserves the quick-reset property of the original policy, without forcing 8K to be allocated to every context whether any of it is ever used or not. Also, remove some more no-longer-needed explicit freeing during ExecEndPlan.
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
* Copyright (c) 2002, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.11 2002/12/15 16:17:42 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.12 2002/12/15 21:01:34 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -256,9 +256,9 @@ StoreQuery(const char *stmt_name, List *query_list, List *plan_list,
|
||||
/* Make a permanent memory context for the hashtable entry */
|
||||
entrycxt = AllocSetContextCreate(TopMemoryContext,
|
||||
stmt_name,
|
||||
1024,
|
||||
1024,
|
||||
ALLOCSET_DEFAULT_MAXSIZE);
|
||||
ALLOCSET_SMALL_MINSIZE,
|
||||
ALLOCSET_SMALL_INITSIZE,
|
||||
ALLOCSET_SMALL_MAXSIZE);
|
||||
|
||||
oldcxt = MemoryContextSwitchTo(entrycxt);
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.141 2002/11/25 03:36:50 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.142 2002/12/15 21:01:34 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -2008,13 +2008,9 @@ deferredTriggerInvokeEvents(bool immediate_only)
|
||||
void
|
||||
DeferredTriggerInit(void)
|
||||
{
|
||||
/*
|
||||
* Since this context will never be reset, give it a minsize of 0.
|
||||
* This avoids using any memory if the session never stores anything.
|
||||
*/
|
||||
deftrig_gcxt = AllocSetContextCreate(TopMemoryContext,
|
||||
"DeferredTriggerSession",
|
||||
0,
|
||||
ALLOCSET_DEFAULT_MINSIZE,
|
||||
ALLOCSET_DEFAULT_INITSIZE,
|
||||
ALLOCSET_DEFAULT_MAXSIZE);
|
||||
}
|
||||
@ -2041,12 +2037,11 @@ DeferredTriggerBeginXact(void)
|
||||
|
||||
/*
|
||||
* Create the per transaction memory context and copy all states from
|
||||
* the per session context to here. Set the minsize to 0 to avoid
|
||||
* wasting memory if there is no deferred trigger data.
|
||||
* the per session context to here.
|
||||
*/
|
||||
deftrig_cxt = AllocSetContextCreate(TopTransactionContext,
|
||||
"DeferredTriggerXact",
|
||||
0,
|
||||
ALLOCSET_DEFAULT_MINSIZE,
|
||||
ALLOCSET_DEFAULT_INITSIZE,
|
||||
ALLOCSET_DEFAULT_MAXSIZE);
|
||||
oldcxt = MemoryContextSwitchTo(deftrig_cxt);
|
||||
|
Reference in New Issue
Block a user