Skip to content

Commit 0b885e2

Browse files
committed
Release allocated memory during AtAbort_Memory.
1 parent eb4d9f4 commit 0b885e2

File tree

1 file changed

+35
-6
lines changed
  • src/backend/access/transam

1 file changed

+35
-6
lines changed

src/backend/access/transam/xact.c

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.34 1999/05/09 00:52:08 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.35 1999/05/13 00:34:57 tgl Exp $
1111
*
1212
* NOTES
1313
* Transaction aborts can now occur two ways:
@@ -690,13 +690,27 @@ AtCommit_Locks()
690690
static void
691691
AtCommit_Memory()
692692
{
693+
Portal portal;
694+
MemoryContext portalContext;
695+
693696
/* ----------------
694-
* now that we're "out" of a transaction, have the
697+
* Release memory in the blank portal.
698+
* Since EndPortalAllocMode implicitly works on the current context,
699+
* first make real sure that the blank portal is the selected context.
700+
* (This is probably not necessary, but seems like a good idea...)
701+
* ----------------
702+
*/
703+
portal = GetPortalByName(NULL);
704+
portalContext = (MemoryContext) PortalGetHeapMemory(portal);
705+
MemoryContextSwitchTo(portalContext);
706+
EndPortalAllocMode();
707+
708+
/* ----------------
709+
* Now that we're "out" of a transaction, have the
695710
* system allocate things in the top memory context instead
696711
* of the blank portal memory context.
697712
* ----------------
698713
*/
699-
EndPortalAllocMode();
700714
MemoryContextSwitchTo(TopMemoryContext);
701715
}
702716

@@ -770,10 +784,25 @@ AtAbort_Locks()
770784
static void
771785
AtAbort_Memory()
772786
{
787+
Portal portal;
788+
MemoryContext portalContext;
789+
790+
/* ----------------
791+
* Release memory in the blank portal.
792+
* Since EndPortalAllocMode implicitly works on the current context,
793+
* first make real sure that the blank portal is the selected context.
794+
* (This is ESSENTIAL in case we aborted from someplace where it wasn't.)
795+
* ----------------
796+
*/
797+
portal = GetPortalByName(NULL);
798+
portalContext = (MemoryContext) PortalGetHeapMemory(portal);
799+
MemoryContextSwitchTo(portalContext);
800+
EndPortalAllocMode();
801+
773802
/* ----------------
774-
* after doing an abort transaction, make certain the
775-
* system uses the top memory context rather then the
776-
* portal memory context (until the next transaction).
803+
* Now that we're "out" of a transaction, have the
804+
* system allocate things in the top memory context instead
805+
* of the blank portal memory context.
777806
* ----------------
778807
*/
779808
MemoryContextSwitchTo(TopMemoryContext);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy