Hi Mark

> I have an application that polls for the existence of rows in a table
> every second by a select statement.  It then processes them and deletes
> them.  99% of the time, no rows are available.
> 
> An *odbx_result_finish* is always when I exit.
> 
> The problem is that each poll (select statement) results in the server
> allocating 128KB that is not released.  Needless to say that after a
> while, the server runs out of memory.

The required loop for your application should be like this:

while( condition )
{
        odbx_query( "SELECT ..." );
        while( ( err = odbx_result() ) != ODBX_RES_DONE )
        {
                if( err < 0 ) { /* handle error */ continue; }
                switch( err )
                {
                        case ODBX_RES_TIMEOUT:
                                /* handle timeout */
                                continue;
                        case ODBX_RES_NOROWS:
                                odbx_result_finish();
                                continue;
                }

                while( odbx_row_fetch() != ODBX_ROW_DONE )
                {
                        // do work
                }

                odbx_result_finish();
        }
}

It's important that you call odbx_result_finish() after each each call to 
odbx_result as long as it returns ODBX_RES_NOROWS or ODBX_RES_ROWS. 
Otherwise, you will get the memory leak you've decribed. Please also have a 
look at the test/odbx-regression.c file for a working example.


Norbert
-- 
OpenPGP public key
http://www.linuxnetworks.de/norbert.pubkey.asc

Attachment: signature.asc
Description: This is a digitally signed message part.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
libopendbx-devel mailing list
libopendbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libopendbx-devel
http://www.linuxnetworks.de/doc/index.php/OpenDBX

Reply via email to