Oracle FAQ Your Portal to the Oracle Knowledge Grid

Home -> Community -> Usenet -> c.d.o.server -> Re: OCI, binding and memory usage

Re: OCI, binding and memory usage

From: Ken Wallis <>
Date: Tue, 9 Jul 2002 09:29:59 +1000
Message-ID: <1dpW8.675$>

"Eric" <> wrote

It is odd, isn't it. For pretty much everything else you have to explicitly allocate and free the handles,
but for an OCIBind or OCIDefine handle you just declare it and use it.

As I understand it, if you reuse the same OCIBind * handle then Oracle handles the clean up of anything
left over from the last time it was used. There may not even be any memory allocation involved, since the handles
ought really to be associated with the prepared statement and its placeholders.

I haven't had a problem with this and I have processes running for a long time, regularly re-binding different
addresses to the same statements and re-executing them. I'm not seeing leakage.

HTH, Ken Wallis

> I'm a relative newcomer to OCI 8 programming. I am confused by some
> of the OCI documentation, specifically related to OCIBindByPos.
> What I want to do is this:
> - prepare a PL/SQL statement once
> - bind input and output to program variables; for each execution of
> the statement, the location of the bind variables may be different
> - execute the statement many times
> It's unclear what happens with regard to allocation and deallocation
> of the *bindpp variables. The documentation implies that each time
> OCIBindByPos is called, a bindpp struct will be allocated, and that
> once the statement handle is freed, all associated bindpp structs are
> also freed.
> Assume I have one variable to bind in the statement, and I need to
> execute the statement 1 million times, storing the result in different
> places each time (or at least, unpredictable memory locations each
> time, probably some overlap). So I call OCIBindByPos 1 million
> times...does this mean OCI will allocate the bindpp 1 million times?
> And is OCIHandleFree really smart enough to free the bindpp pointers
> for all 1 million cases, or just the last one?
> Very confusing. All I want to do is really change the location of
> each parameter in memory, and nothing else. The statement remains the
> same, the parameters remain the same, the data types remain the same.
Received on Mon Jul 08 2002 - 18:29:59 CDT

Original text of this message