Re: [HACKERS] Everything leaks; How it mm suppose to work?

From: Massimo Dal Zotto <dz(at)cs(dot)unitn(dot)it>
To: hackers(at)postgreSQL(dot)org (Pgsql Development)
Cc: dg(at)illustra(dot)com (David Gould)
Subject: Re: [HACKERS] Everything leaks; How it mm suppose to work?
Date: 1998-04-09 10:31:42
Message-ID: 199804091031.MAA01465@pennac.cs.unitn.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> Bruce:
> > Maurice:
> > > >Running postgresql in interactive mode shows that for each query I
> > > >type there is memory lost. The exact amount of memory lost depends on
> > > >the query I use. The amount of memory not freed is also a function
> > > >of the number of tuples returned.
> > > >
> > >
> > > Oops, it seems some palloced memory is not freed by pfree but
> > > using some other function(s).
> > > My mistake, sorry.
> > >
> >
> > One thing I have found is that:
> >
> > select * from test where 1=0;
> >
> > do not leak memory while
> >
> > select * from test where x=-999;
> >
> > does leak memory, even though neither returns any rows. Strange. Would
> > seem to point to the optimizer or executor.
>
> In the first case, the where clause is constant and evaluates false, so
> not much is done. In the second case, the table is scanned and presumably
> some memory is allocated for each row, probably to evaluate the expression.
> Since this memory is allocated into a per statement duration, it will not
> be freed until the end of the statement when the context is destroyed.
>
> -dg
>

Does it make sense to have a 'row' context which is released just before
starting with a new tuple ? The total number or free is the same but they
are distributed over the query and unused memory should not accumulate.
I have seen backends growing to 40-60MB with queries which scan a very
large number of rows.

Massimo Dal Zotto

+----------------------------------------------------------------------+
| Massimo Dal Zotto e-mail: dz(at)cs(dot)unitn(dot)it |
| Via Marconi, 141 phone: ++39-461-534251 |
| 38057 Pergine Valsugana (TN) www: http://www.cs.unitn.it/~dz/ |
| Italy pgp: finger dz(at)tango(dot)cs(dot)unitn(dot)it |
+----------------------------------------------------------------------+

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Maurice Gittens 1998-04-09 11:00:09 Re: [HACKERS] Everything leaks; How it mm suppose to work?
Previous Message David Gould 1998-04-09 08:03:56 Re: [HACKERS] On improving OO support in posgresql and relaxing oid bottleneck at the same time