Re: Postgres eats up memory when using cursors

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Denis Perchine <dyp(at)perchine(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Postgres eats up memory when using cursors
Date: 2001-03-01 18:12:16
Message-ID: Pine.LNX.4.30.0103011839500.760-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gmx(dot)net http://yi.org/peter-e/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Anthony Metzidis 2001-03-01 18:28:14 PG_PWD and PG_PASSWORD Security
Previous Message Gregory Wood 2001-03-01 17:27:45 Re: JOIN of a table with many detail tables