Jorge Arevalo <jorgearev...@gis4free.org> writes: > BTW, this code is for WKT Raster. A PostGIS extension. We can use the > memory context I said (fcinfo->flinfo->fn_mcxt) to allocate memory > when we need to call one of our functions from a standard "version 1" > function, but is this the right context? I mean, the context we should > use for a whole-plugin-lifetime persistence.
fn_mcxt will typically point at a query-lifespan context. If you need to allocate storage that will live as long as the session, there's not that much reason not to use malloc, except perhaps that you have to remember to do your own out-of-memory-failure checks. The typical coding pattern in the backend for session-lifespan storage is to use TopMemoryContext, or possibly make your own context (as a child of TopMemoryContext) so that you can easily identify how much storage you're using for this purpose. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general