From 2970afa6cf1057107c998bf3cdd1fbf6dc78cf6c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 11 Sep 2018 18:45:02 -0400 Subject: Add PQresultMemorySize function to report allocated size of a PGresult. This number can be useful for application memory management, and the overhead to track it seems pretty trivial. Lars Kanis, reviewed by Pavel Stehule, some mods by me Discussion: https://postgr.es/m/fa16a288-9685-14f2-97c8-b8ac84365a4f@greiz-reinsdorf.de --- doc/src/sgml/libpq.sgml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'doc/src') diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index 5e7931ba901..06d909e8049 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -6387,6 +6387,32 @@ void *PQresultAlloc(PGresult *res, size_t nBytes); + + + PQresultMemorySize + + PQresultMemorySize + + + + + + Retrieves the number of bytes allocated for + a PGresult object. + +size_t PQresultMemorySize(const PGresult *res); + + + + + This value is the sum of all malloc requests + associated with the PGresult object, that is, + all the space that will be freed by PQclear. + This information can be useful for managing memory consumption. + + + + PQlibVersion @@ -6960,6 +6986,14 @@ void *PQinstanceData(const PGconn *conn, PGEventProc proc); int PQresultSetInstanceData(PGresult *res, PGEventProc proc, void *data); + + + Beware that any storage represented by data + will not be accounted for by PQresultMemorySize, + unless it is allocated using PQresultAlloc. + (Doing so is recommendable because it eliminates the need to free + such storage explicitly when the result is destroyed.) + -- cgit v1.2.3