Re: Memory leak somewhere at PQconnectdb?

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: Memory leak somewhere at PQconnectdb?
Дата
Msg-id 4E60472F.7080706@ringerc.id.au
обсуждение исходный текст
Ответ на Memory leak somewhere at PQconnectdb?  (Antonio Vieiro <antonio@antonioshome.net>)
Ответы Re: Memory leak somewhere at PQconnectdb?
Список pgsql-general
On 01/09/11 22:08, Antonio Vieiro wrote:
> Hi all,
>
> I'm running one of my programs with valgrind to check for memory leaks
> and I'm seeing something like this:

You only get the one report, though, right? No matter how many times
PQconnectdb is run in a loop?

It's internal stuff within OpenSSL. If you really want to you can call:

  CONF_modules_free()

before your program terminates, to make sure OpenSSL cleans up its data
structures. Just make sure nobody else has registered an atexit()
handler that touches OpenSSL or you'll get fireworks.

PostgreSQL (libpq) should not be responsible for cleaning up OpenSSL,
and *cannot* be reliably responsible for it. If libpq tried to clean up
OpenSSL it might well "clean" it while other libraries or the main
application code was still using it for something else.

If you want to avoid this warning, call OPENSSL_config yourself before
doing anything in libpq, and call CONF_modules_free before exit. That
way libpq's call to OPENSSL_config becomes a no-op and you have full
control of OpenSSL's init and cleanup.

Even better, add a valgrind suppressions file for the warnings and
ignore them. They are "leaks" only in the sense that a static variable
is a leak, ie not at all.

If you see that the program grows if you run it many times in a loop,
and you get more and more leak records for every loop, *THEN* there
might be a problem.


--
Craig Ringer

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Why schema of table is removed from explain?
Следующее
От: Diego Augusto Molina
Дата:
Сообщение: Re: How can I merge two tables?