From: | "Jack Orenstein" <jack(dot)orenstein(at)gmail(dot)com> |
---|---|
To: | "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, "Jack Orenstein" <jack(dot)orenstein(at)gmail(dot)com>, "Andrew - Supernews" <andrew(at)supernews(dot)net>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Initializing Datums for use with SPI_execute_plan |
Date: | 2006-09-19 20:00:43 |
Message-ID: | 7ecd811f0609191300h41d0c21ajca43f64510b79e35@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 9/19/06, Martijn van Oosterhout <kleptog(at)svana(dot)org> wrote:
> On Tue, Sep 19, 2006 at 01:27:56PM -0400, Jack Orenstein wrote:
> > On 9/18/06, Jack Orenstein <jack(dot)orenstein(at)gmail(dot)com> wrote:
> > >---------- Forwarded message ----------
> > >From: Andrew - Supernews <andrew(at)supernews(dot)net>
> > ...
> > > 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
From | Date | Subject | |
---|---|---|---|
Next Message | Ron Johnson | 2006-09-19 20:32:45 | Re: Load a csv file into a pgsql table |
Previous Message | Martijn van Oosterhout | 2006-09-19 19:34:27 | Re: Initializing Datums for use with SPI_execute_plan |