Re: When is the MessageContext released? - Mailing list pgsql-hackers

From Andres Freund
Subject Re: When is the MessageContext released?
Date
Msg-id 20190227061544.kuynkcteqiiot6al@alap3.anarazel.de
Whole thread Raw
In response to When is the MessageContext released?  (Andy Fan <zhihui.fan1213@gmail.com>)
Responses Re: When is the MessageContext released?  (Andy Fan <zhihui.fan1213@gmail.com>)
List pgsql-hackers
On 2019-02-27 14:08:47 +0800, Andy Fan wrote:
> Hi :
>   I run a query like "select * from t" and set the break like this:
> 
> break exec_simple_query
> break MemoryContextDelete
>   commands
>    p context->name
>    c
>   end
> 
> I can see most of the MemoryContext is relased, but never MessageContext,
> when will it be released?

It's released above exec_simple_query, as it actually contains the data
that lead us to call exec_simple_query().  See the main for loop in
PostgresMain():

        /*
         * Release storage left over from prior query cycle, and create a new
         * query input buffer in the cleared MessageContext.
         */
        MemoryContextSwitchTo(MessageContext);
        MemoryContextResetAndDeleteChildren(MessageContext);

Greetings,

Andres Freund


pgsql-hackers by date:

Previous
From: Richard Guo
Date:
Subject: Re: NOT IN subquery optimization
Next
From: Michael Paquier
Date:
Subject: Re: psql display of foreign keys