Thomas Hallgren <thomas@tada.se> writes:
> But if I, during the SPI_IS_FIRST_CALL phase, do an SPI_connect
> (done when the 'multi_call_memory_ctx' is current), then the leak seem
> to occur immediately. Will that connect somehow alter the durability for
> the context that is current on each call to my SRF?
Are you remembering to SPI_finish when you're done? Maybe what you are
leaking is the SPI state information.
You could look at the MemoryContextStats printout for clues --- easiest
way is to deliberately run the backend out of memory, and after the "out
of memory" error occurs, look in the postmaster log.
regards, tom lane