Re: How to properly fix memory leak

From: Igor Korot <ikorot01(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: How to properly fix memory leak
Date: 2025-04-27 04:58:00
Message-ID: CA+FnnTxb=A9F4qw1oN6noatGC0UtE6OUgDe+K-J08YFUaOfJXQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

David et al,

On Fri, Apr 25, 2025 at 10:48 PM David G. Johnston
<david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
> On Friday, April 25, 2025, Igor Korot <ikorot01(at)gmail(dot)com> wrote:
>>
>>
>> for( int i = 0; i < PQntuples( res ); i++ )
>> {
>> auto temp1 = m_pimpl->m_myconv.from_bytes( PQgetvalue(
>> res, i, 1 ) );
>> m_tablespaces.push_back( temp1 );
>> } // this line gives a leak according to VLD
>> }
>> PQclear( res );
>> return result;
>> [/code]
>>
>> I ran this code on MSVC 2017 with VLD and according to the VLD report I have
>> a memory leak on the line indicated.
>
>
> Seems like a false positive.

Looks like it is false positive.

I ran the code under valgrind and there I didn't get
such a leak.
I did however get a different issues which I fixed.
But even after moving the fixes ober to Windows and trying
to run it - I still see that.

For now I put this to bed as it is not an issue on Linux.

Thank you.

>
>>
>>
>> Should I call PQclear() on every iteration of the loop?
>
>
> Would make processing more than a single row impossible if you throw away the result after processing one row.
>
> David J.
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2025-04-27 13:54:24 Re: Changing default fillfactor for the whole database
Previous Message David Rowley 2025-04-27 03:30:24 Re: Changing default fillfactor for the whole database