Re: Avoid resource leak (src/test/regress/pg_regress.c)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoid resource leak (src/test/regress/pg_regress.c)
Date: 2025-10-24 13:03:48
Message-ID: CAEudQArofjr3a235eN_nwmAztxB3pc01o4gHQnn3VREOYsf1XQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em sex., 24 de out. de 2025 às 09:21, Álvaro Herrera <alvherre(at)kurilemu(dot)de>
escreveu:

> On 2025-Oct-24, Ranier Vilela wrote:
>
> > Em sex., 24 de out. de 2025 às 03:03, Michael Paquier
> > <michael(at)paquier(dot)xyz> escreveu:
>
> > > This is just one of them, allocated in the context of what is a
> > > short-term execution.
> >
> > In this case, I believe pg_regress is run, thousands of times, on
> > hundreds of computers.
>
> Yes, but the memory is released at the end of the program execution,
> every single one of those times.
>
Yeah, for sure.
But not before thousands of tests were carried out.

The allocated memory is useless until the program exits.
According to getaddrinfo documentation:
"The *getaddrinfo*() function allocates and initializes a linked list

of *addrinfo* structures, one for each network address that matches
*node* and *service*, subject to any restrictions imposed by *hints*,
and returns a pointer to the start of the list in *res*. The items
in the linked list are linked by the *ai_next* field.

There are several reasons why the linked list may have more than
one *addrinfo* structure, including: the network host is multihomed,
accessible over multiple protocols"

best regards
Ranier Vilela

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2025-10-24 13:16:28 Re: use SIMD in GetPrivateRefCountEntry()
Previous Message Tomas Vondra 2025-10-24 12:43:40 Re: WIP: parallel GiST index builds