I use the Sqlite in the PDA which is WinCE OS. I need
to add more than 200,000 records. I used
sqlite3_prepare->
sqlite3_bind_blob->sqlite3_step->sqlite3_finalize to
write each record in to Database. However, I found
that after each record is inserted, the PDA memory
became larger and larger. In the end, the whole PDA
memory is occupied by this application and the system
halt. Is there any thing I miss to release the memory?
Following is my code:

sqlite3 *db;
sqlite3_stmt * stat;
char *zErrMsg = 0;
char sqlcmd[ 512 ];
int rc;
char chrBarCode[ 16 ], chrPrintData[ 512 ];
int tagtype;



for( i = 0; i < 2000000; i ++ )
{       
        sprintf( sqlcmd, "INSERT INTO TEST( BARCODE, TAGTYPE,
PRINTDATA ) VALUES( %s, %d, ? );", chrBarCode, tagtype
);
        
        rc = sqlite3_prepare( db, sqlcmd, -1, &stat, 0 );
        if( rc != SQLITE_OK )
        {
            sqlite3_close(db);
            return -1;
        }
        
        rc = sqlite3_bind_blob( stat, 1, chrPrintData,
length, NULL ); 
        if( rc != SQLITE_OK )
        {
            sqlite3_close(db);
            return -1;
        }
        
        rc = sqlite3_step( stat );                      
        if( rc != SQLITE_DONE )
        {
            sqlite3_close(db);
            return -1;
        }
        
        rc = sqlite3_reset( stat );
        if( rc != SQLITE_OK )
        {
            sqlite3_close(db);
            return -1;
        }
        
        rc = sqlite3_finalize( stat );
        if( rc != SQLITE_OK )
        {
            sqlite3_close(db);
            return -1;
        }
        
}


WenYuan



      ______________________________________________________________________
Search, browse and book your hotels and flights through Yahoo! Travel.
http://sg.travel.yahoo.com
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to