Re: Fix memory leak in gist_page_items() of pageinspect

Поиск
Список
Период
Сортировка
От Chao Li
Тема Re: Fix memory leak in gist_page_items() of pageinspect
Дата
Msg-id CAEoWx2=0opy1W8+wX3hNBDYkYrWSETxd1t8OFvX7-u4zR17TVQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Fix memory leak in gist_page_items() of pageinspect  (Daniel Gustafsson <daniel@yesql.se>)
Список pgsql-hackers


On Dec 12, 2025, at 18:29, Daniel Gustafsson <daniel@yesql.se> wrote:

On 12 Dec 2025, at 11:27, Heikki Linnakangas <hlinnaka@iki.fi> wrote:

If we're going to bother changing this at all, let's consider reusing the buffer. So instead of initStringInfo()+pfree on every tuple, allocate it once and use resetStringInfo().

+1


It looks like there’s no disagreement on the index_close() fix, while the StringInfo change has triggered some discussion.

So I’ve split the fix into two commits, which I probably should have done from the beginning. 0001 contains the index_close() fix, and 0002 contains the StringInfo fix.

As Heikki suggested, I switched to using resetStringInfo() in 0002. One thing I’d like to highlight is that this function only uses the StringInfo buffer under certain conditions. If we initialize the StringInfo unconditionally, that feels wasteful; if we initialize it lazily, as in 0002, then we need some extra checks to manage its state.


Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/




Вложения

В списке pgsql-hackers по дате отправления: