Subject RE: [IBO] Prepared Statements and Memory Usage
Author Ryan Thomas
Hi Helen,

The code after the prepare iterates through the parameters and sets them
with the Params->Columns[a]->AsString property.

>
> Also, do you have any handler code in OnPrepareSQL?

No, no code in there.

>
> Do you have any blobs as parameters? If so, are you binding
> them to any run-time objects (stream, TStrings) that you are
> forgetting to destroy afterwards? Or are you maybe reading
> the entire source data for a row into some kind of run-time
> structure that keeps getting created but is never destroyed?

The parameters are stored in a vector<AnsiString>, which is deleted after
each use. I don't think that it is the structure hanging around because the
mem use is stable when destroying and re-creating the TIB_DSQL.

The memory jump occurs after the first set of parameters have been populated
and Execute() called (the first iteration). It jumps as soon as I step over
Prepare() in the second iteration (Unprepare() is called right before this).

Once the process is running (using the delete/recreate TIB_DSQL method) the
memory usage sits at around 21Mb for the duration of the processing (about
600 records in this case). Without the delete/recreate the usage of the
process goes up until about 800Mb and has to be killed before it becomes
impossible to kill, this happens after about 130 records.

This was why I thought it had something to do with clearing the parameters -
as it seems everything is cleared on deletion.

> >I havent been able to try the ClearBuffers because I keep getting an
> >Ambiguity compile time error (with the rsNone), is anyone
> able to help
> >out with what namespace this is in?
>
> It's a member of the enumerated set TIB_Rowstate. In a DSQL,
> you have only one TIB_Row object: the Params[] array. Stay
> away from methods pertaining to buffers, because there are no
> buffers other than Params, which Params.Clear takes care of
> specifically. It literally removes all of the individual
> IB_Column objects in Params, i.e. makes ParamCount 0.
>
> Helen
>

Cheers,

Ryan Thomas
TransActive Systems

>
>
> ______________________________________________________________
> _____________
> IB Objects - direct, complete, custom connectivity to
> Firebird or InterBase
> without the need for BDE, ODBC or any other layer.
> ______________________________________________________________
> _____________
> http://www.ibobjects.com - your IBO community resource for
> Tech Info papers,
> keyword-searchable FAQ, community code contributions and more
> !
> Yahoo! Groups Links
>
>
>
>
>
>
>
>