Retrieve memory size allocated by libpq

From: Lars Kanis <lars(at)greiz-reinsdorf(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Sam Saffron <sam(dot)saffron(at)gmail(dot)com>
Subject: Retrieve memory size allocated by libpq
Date: 2018-06-23 19:58:43
Message-ID: fa16a288-9685-14f2-97c8-b8ac84365a4f@greiz-reinsdorf.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

I would like to be able to retrieve the size of memory internally
allocated by libpq for a result. The reason is that we have a Ruby
wrapper that exposes libpq in Ruby. The problem is that Ruby's GC
doesn't know how much memory has been allocated by libpq, so no pressure
is applied to the GC when it should be. With this function we could
instruct the GC about the memory usage associated to each result object.

This issue has already been discussed in the following thread, with the
request to use custom malloc/realloc/free functions:

https://www.postgresql.org/message-id/flat/20170828172834(dot)GA71455%40TC(dot)local#20170828172834(dot)GA71455(at)TC(dot)local

Retrieving the allocated memory size is another approach to solve the
same base issue. However since the relation between memory consumption
and the particular result object is maintained, it can additionally be
used to provide diagnostic information to each object.

What do you think about adding such a function?

--
Kind Regards,
Lars

Attachment Content-Type Size
0001-libpq-Add-function-PQresultMemsize.patch text/x-patch 4.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2018-06-23 20:08:21 Re: Log query parameters for terminated execute
Previous Message Sergei Kornilov 2018-06-23 19:54:19 Log query parameters for terminated execute