BUG #2422: Memory leak from Savepoints when using foreign keys - Mailing list pgsql-bugs

From Tim Baumgartner
Subject BUG #2422: Memory leak from Savepoints when using foreign keys
Date
Msg-id 200605051009.k45A9QFF003750@wwwmaster.postgresql.org
Whole thread Raw
List pgsql-bugs
The following bug has been logged online:

Bug reference:      2422
Logged by:          Tim Baumgartner
Email address:      jongleur0815@gmx.de
PostgreSQL version: 8.1.3
Operating system:   1. Win2000, 2. Suse 10.0, x86_64-unknown-linux-gnu,
compiled by GCC  4.0.2 20050901 (prerelease)
Description:        Memory leak from Savepoints when using foreign keys
Details:

I noticed a memory leak during a long transaction with many savepoints. When
trying to build a short self-contained test case for it, I noticed that the
existence of foreign keys dramatically increases the problem.
When I run the statements below, memory usage of the server process
increases by about 1 MB per second.

BEGIN;
 CREATE TABLE t1(pk INT PRIMARY KEY);
 CREATE TABLE t2(fk INT, FOREIGN KEY(fk)
      REFERENCES t1(pk));
 INSERT INTO t1 VALUES(1);
 // loop
    SAVEPOINT x;
    INSERT INTO t2 VALUES(1);
    RELEASE x;
 // end of loop
COMMIT;

Note:
If the first INSERT statement is repeated in the loop (the loop counter can
be used as the value), then the effect is even higher: about 3 MB per second
on my machine.

Thanks a lot for your fine work anyway!

pgsql-bugs by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: BUG #2418: number & date & time
Next
From: "Andy Male"
Date:
Subject: BUG #2419: could not reattach to shared memory