Re: Curing plpgsql's memory leaks for statement-lifespan values

From: Dilip Kumar <dilipbalaut(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Curing plpgsql's memory leaks for statement-lifespan values
Date: 2016-07-24 13:12:51
Message-ID: CAFiTN-uLBa3KOUUXGGWn9rxXgkc0MkBCJ4jKeon7p84+qEqw2A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jul 24, 2016 at 12:40 PM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
wrote:

> In short, why do you think
> it is better to create a new context rather than using "SPI Exec"?
>

I think life span of the memory allocated from "SPI Exec" is only within
"Executor", and after that SPI_Exec
will be reset. But many places we need such memory beyond "Executor"(including
one which is reported in above issue).

If we see below example of exec_stmt_dynexecute.
exec_stmt_dynexecute

{

....

querystr = pstrdup(querystr);

SPI_Execute --> inside this SPI_Exec context will be reset.

After this querystr is being used in this function.

}
--
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-07-24 15:47:55 Re: Curing plpgsql's memory leaks for statement-lifespan values
Previous Message Michael Paquier 2016-07-24 12:18:45 Re: Re: GiST optimizing memmoves in gistplacetopage for fixed-size updates [PoC]