Re: Many Pl/PgSQL parameters -> AllocSetAlloc(128)? - Mailing list pgsql-general

From Joe Conway
Subject Re: Many Pl/PgSQL parameters -> AllocSetAlloc(128)?
Date
Msg-id 3EF7F77D.4050409@joeconway.com
Whole thread Raw
In response to Re: Many Pl/PgSQL parameters -> AllocSetAlloc(128)?  (Joe Conway <mail@joeconway.com>)
Responses Re: Many Pl/PgSQL parameters -> AllocSetAlloc(128)?  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Many Pl/PgSQL parameters -> AllocSetAlloc(128)?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Joe Conway wrote:
> I get nanswers = 16777216, so right off the bat 67MB or so is allocated.
> Then there's this:
>
> <snippet>
>     /* compute the cross product from right to left */
>     for (;;)
>     {
>         oneres = (Oid *) palloc0(FUNC_MAX_ARGS * sizeof(Oid));
> </snippet>
>
> I'm guessing this gets executed nanswers times. I saw memory usage grow
> to 880 MB and then killed the process.
>
> I'm not sure of the best way to fix this yet, but I found that when
> calling the function with argument types matching the prototype
> perfectly, this code never gets executed.

Actually, adding a "pfree(oneres);" to the end of that for loop plugs
the memory leak and allows me to see the error message:

ERROR:  Function add_news__test(integer, character varying, timestamp
with time zone, character varying, character varying, character varying,
character varying, integer, timestamp with time zone, integer, timestamp
with time zone, character varying, character varying, character varying,
integer, boolean, character varying, character varying, character
varying, timestamp with time zone, integer, character varying, character
varying, integer) does not exist
         Unable to identify a function that satisfies the given argument
types
         You may need to add explicit typecasts

Takes a while to check all 16777216 possibilities though, so I'm still
not sure more isn't needed here.

Joe


pgsql-general by date:

Previous
From: nolan@celery.tssi.com
Date:
Subject: Re: [pgsql-advocacy] Documentation quality WAS: interesting PHP/MySQL thread
Next
From: culley harrelson
Date:
Subject: Re: [pgsql-advocacy] interesting PHP/MySQL thread