diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2018-09-11 18:45:02 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2018-09-11 18:45:12 -0400 |
commit | 2970afa6cf1057107c998bf3cdd1fbf6dc78cf6c (patch) | |
tree | 278f0ae05b7fb72fdde9422f16a231373014da99 /doc/src | |
parent | e7a2217978d9cbb2149bfcb4ef1e45716cfcbefb (diff) |
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
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/libpq.sgml | 34 |
1 files changed, 34 insertions, 0 deletions
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); </listitem> </varlistentry> + <varlistentry id="libpq-pqresultmemorysize"> + <term> + <function>PQresultMemorySize</function> + <indexterm> + <primary>PQresultMemorySize</primary> + </indexterm> + </term> + + <listitem> + <para> + Retrieves the number of bytes allocated for + a <structname>PGresult</structname> object. +<synopsis> +size_t PQresultMemorySize(const PGresult *res); +</synopsis> + </para> + + <para> + This value is the sum of all <function>malloc</function> requests + associated with the <structname>PGresult</structname> object, that is, + all the space that will be freed by <function>PQclear</function>. + This information can be useful for managing memory consumption. + </para> + </listitem> + </varlistentry> + <varlistentry id="libpq-pqlibversion"> <term> <function>PQlibVersion</function> @@ -6960,6 +6986,14 @@ void *PQinstanceData(const PGconn *conn, PGEventProc proc); int PQresultSetInstanceData(PGresult *res, PGEventProc proc, void *data); </synopsis> </para> + + <para> + Beware that any storage represented by <parameter>data</parameter> + will not be accounted for by <function>PQresultMemorySize</function>, + unless it is allocated using <function>PQresultAlloc</function>. + (Doing so is recommendable because it eliminates the need to free + such storage explicitly when the result is destroyed.) + </para> </listitem> </varlistentry> |