Re: Valgrind - showing memory leaks

2025-05-11 Thread Tom Lane
=?utf-8?Q?=C3=81lvaro?= Herrera writes: > On 2025-May-08, Tom Lane wrote: >> So it seems like valgrind is wrong here, or else we're leaking the >> whole rd_att structure later on somehow. > Well, the problem is that if num_check is zero, FreeTupleDesc() doesn't > free ->check. Ah-hah. > Done th

Re: Valgrind - showing memory leaks

2025-05-11 Thread Álvaro Herrera
On 2025-May-08, Tom Lane wrote: > Uh ... yeah it is, down at the bottom of the function: > > /* Install array only after it's fully valid */ > relation->rd_att->constr->check = check; > relation->rd_att->constr->num_check = found; > > So it seems like valgrind is wrong here, or

Re: Valgrind - showing memory leaks

2025-05-08 Thread Yasir
On Thu, May 8, 2025 at 6:17 PM Álvaro Herrera wrote: > On 2025-05-08, Yasir wrote: > > > I believe that the valgrind should not report any memory leaks in such > > simple/common commands. What am I doing wrong here? > > Hmm, that function was modified relatively recently so I think you found a >

Re: Valgrind - showing memory leaks

2025-05-08 Thread Álvaro Herrera
On 2025-May-08, Tom Lane wrote: > Alvaro seems to think CheckNNConstraintFetch is worth taking > a second look at, and maybe he's right, but the amount of > storage involved there seems unexciting too. Yeah, I think the new issue here is that we're calling that function at all; previously we woul

Re: Valgrind - showing memory leaks

2025-05-08 Thread Tom Lane
=?utf-8?Q?=C3=81lvaro?= Herrera writes: > If the table doesn't have check constraints, we end up doing > MemoryContextAllocZero() with size 0 in CacheMemoryContext, which isn't > great (IIUC we innecessarily allocate a chunk of size 8 in this case). > I think we should make the allocation conditio

Re: Valgrind - showing memory leaks

2025-05-08 Thread Yasir
On Thu, May 8, 2025 at 7:27 PM Tom Lane wrote: > Yasir writes: > > I believe that the valgrind should not report any memory leaks in such > > simple/common commands. What am I doing wrong here? > > I think you are vastly overestimating both the intelligence of > valgrind, and our level of concer

Re: Valgrind - showing memory leaks

2025-05-08 Thread Tom Lane
Yasir writes: > I believe that the valgrind should not report any memory leaks in such > simple/common commands. What am I doing wrong here? I think you are vastly overestimating both the intelligence of valgrind, and our level of concern about minor one-time leaks. Most of these are probably not

Re: Valgrind - showing memory leaks

2025-05-08 Thread Álvaro Herrera
On 2025-05-08, Yasir wrote: > I believe that the valgrind should not report any memory leaks in such > simple/common commands. What am I doing wrong here? Hmm, that function was modified relatively recently so I think you found a genuine bug, which is probably mine. I'll have a look ... -- Ál

Re: Valgrind - showing memory leaks?

2025-05-08 Thread Aleksander Alekseev
Hi Yasir > I ran a postgres server with valgrind looking for memory leaks at a > particular extension, but I am experiencing something strange. Here are the > steps: > [...] > 5. Question: > > I believe that the valgrind should not report any memory leaks in such > simple/commo