On 9/19/06, Martijn van Oosterhout <kleptog@xxxxxxxxx> wrote:
On Tue, Sep 19, 2006 at 01:27:56PM -0400, Jack Orenstein wrote: > On 9/18/06, Jack Orenstein <jack.orenstein@xxxxxxxxx> wrote: > >---------- Forwarded message ---------- > >From: Andrew - Supernews <andrew@xxxxxxxxxxxxx> > ... > > Jack> I have an int8 that I need as a Datum for use with > > Jack> SPI_execute_plan. > > > >Int64GetDatum(your_variable) > > which then has to be pfree'd, correct? Possibly, it probably depends on the architechture. The memory is being allocated in a per-call context IIRC so it'll be freed at the end of the function anyway. I wouldn't worry about it.
Can you provide some guidance (or point to some documentation) on how to manage memory? Is the idea that I should (must?) not pfree palloc'ed memory from Int64GetDatum, but I should free anything I allocate myself using palloc? Or not even that? The C extension I'm writing, which uses the SPI, will be called thousands or millions of times as part of a data conversion -- I do have to worry about memory leaks. Once the conversion completes, I won't use the function any longer. But I'd rather not leak memory and have to do something drastic to reclaim it, such as bouncing postgresql. Jack