Re: Detoasting and memory usage - Mailing list pgsql-general

From Joe Conway
Subject Re: Detoasting and memory usage
Date
Msg-id 3F1A24E8.8050302@joeconway.com
Whole thread Raw
In response to Detoasting and memory usage  (apb18@cornell.edu)
Responses Re: Detoasting and memory usage  (apb18@cornell.edu)
List pgsql-general
apb18@cornell.edu wrote:
> I guess my situation is an odd fringe case that probably doesn't happen
> too much, but I thought that knowledge of it might be useful to someone
> somewhere.

See PG_FREE_IF_COPY in fmgr.h

/*
  * Support for cleaning up detoasted copies of inputs.  This must only
  * be used for pass-by-ref datatypes, and normally would only be used
  * for toastable types.  If the given pointer is different from the
  * original argument, assume it's a palloc'd detoasted copy, and pfree
  * it.
  *
  * NOTE: most functions on toastable types do not have to worry about
  * this, but we currently require that support functions for indexes
  * not leak memory.
  */
#define PG_FREE_IF_COPY(ptr,n) \
     do { \
         if ((Pointer) (ptr) != PG_GETARG_POINTER(n)) \
             pfree(ptr); \
     } while (0)

Maybe you can use that or do something similar?

HTH,

Joe


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Horrible pg_restore performance, please help
Next
From: Ken Godee
Date:
Subject: Re: Help with privilege or pg_hba.conf