Re: Is this a memory leak in libpqrcv_processTuples()? - Mailing list pgsql-hackers

From Neil Chen
Subject Re: Is this a memory leak in libpqrcv_processTuples()?
Date
Msg-id CAA3qoJ=1CxTu+JMH3JvO7TJtT-AD+AB2myyKypTLoptgRQx1-g@mail.gmail.com
Whole thread Raw
In response to Re: Is this a memory leak in libpqrcv_processTuples()?  ("Dewei Dai" <daidewei1970@163.com>)
List pgsql-hackers
Hi Chao,

As you mentioned, attinmeta will be automatically freed when the memory context is destroyed. If our concern here is that repeated calls to walrcv_exec in some section of the code are causing a large number of attinmeta objects to remain unreleased(I’m not sure if anyone would use walrcv_exec to do something like this), this would seem to imply that we are repeatedly constructing identical attinmeta instances – for example:

while (loop_condition) {
    sprintf(query, "xxx where xx = %d", index++);
    res = walrcv_exec(conn, query, ...);
}

It is rare to encounter a scenario where walrcv_exec is called multiple times and each invocation uses a query with different attrs. Therefore, if this loop scenario is indeed the case, should we consider avoiding the repeated construction of tupdesc/attinmeta?

pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: eliminate xl_heap_visible to reduce WAL (and eventually set VM on-access)
Next
From: tushar
Date:
Subject: Re: Non-text mode for pg_dumpall