Re: Postgres eats up memory when using cursors - Mailing list pgsql-general

From Peter Eisentraut
Subject Re: Postgres eats up memory when using cursors
Date
Msg-id Pine.LNX.4.30.0103011839500.760-100000@peter.localdomain
Whole thread Raw
In response to Re: Postgres eats up memory when using cursors  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Postgres eats up memory when using cursors
List pgsql-general
Tom Lane writes:

> Curiously, there does seem to be a leak in psql, or possibly libpq,
> when running this script.  It's per-query not per-tuple, so it's
> easier to see if you make the fetches shorter:
>
> fetch 100 from senders_c
> \g zzz
> fetch backward 100 from senders_c
> \g zzz
>
> Repeating these like mad, psql grows about 1Kb/sec on my machine.
> This occurs with current sources but NOT with 7.0.2 psql.  Peter,
> any thoughts about that?

Well, here's a memory leak:

Index: print.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/bin/psql/print.c,v
retrieving revision 1.16
diff -c -r1.16 print.c
*** print.c     2001/02/27 08:13:27     1.16
--- print.c     2001/03/01 17:30:00
***************
*** 1116,1121 ****
--- 1116,1122 ----
                free(footers[0]);
                free(footers);
        }
+       free(align);
  }


===snip

This leaks (columns + 1) per query, 4 bytes in your case.  But is has been
there in 7.0 as well.

I couldn't find anything suspicious in the CVS diffs of psql or libpq
since 7.0.

So let's think:  What if you use COPY?  \copy?  Plain SELECT?  What's the
leakage per query cycle (not per second)?  Is it related to the size of
the data?

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/


pgsql-general by date:

Previous
From: Geoff Russell
Date:
Subject: Set Operators and Arrays Question
Next
From: "Anthony Metzidis"
Date:
Subject: PG_PWD and PG_PASSWORD Security