Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
Thanks Eric, you nailed it on the head! With this parameter I am able to configure the page usage and stop the memory growth where I want it! -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]on Behalf Of Eric Minbiole Sent: Monday, June 29, 2009 12:06 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 > So it seems by best bet is to close and open the connection once every 5 > minutes or so? While this might "work", I don't think you should resort to that. As Kees noted earlier, there will be performance drawbacks if you close/re-open the database. As others have indicated, the heap growth is likely due to SQLite intentionally caching frequently used disk pages in order to improve performance. Rather than closing/re-opening, I suggest that you set the page cache size to a limit that is reasonable for your application: http://www.sqlite.org/pragma.html#pragma_cache_size The default is around 2MB. You can decrease to as little as 10KB. Note that there are some other buffers used by SQLite (Scratch, Lookaside, etc). However, these are typically small compared to the page cache. Additional info here: http://www.sqlite.org/malloc.html ~Eric ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
On 29 Jun 2009, at 1:11pm, Greg Morehead wrote: > So it seems by best bet is to close and open the connection once > every 5 minutes or so? No. The library is unlikely to have a leak of that kind in. Are you certain that what you're seeing is a real leak ? If so, the leak may be in your own code. Otherwise, check to see that SQLite is not staying entirely within the expected cache memory usage: http://www.sqlite.org/pragma.html#pragma_default_cache_size It's possible to manage the cache yourself http://www.sqlite.org/c3ref/pcache_methods.html but frankly this is above my head and I wouldn't know where to start. Simon. ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
> So it seems by best bet is to close and open the connection once every 5 > minutes or so? While this might "work", I don't think you should resort to that. As Kees noted earlier, there will be performance drawbacks if you close/re-open the database. As others have indicated, the heap growth is likely due to SQLite intentionally caching frequently used disk pages in order to improve performance. Rather than closing/re-opening, I suggest that you set the page cache size to a limit that is reasonable for your application: http://www.sqlite.org/pragma.html#pragma_cache_size The default is around 2MB. You can decrease to as little as 10KB. Note that there are some other buffers used by SQLite (Scratch, Lookaside, etc). However, these are typically small compared to the page cache. Additional info here: http://www.sqlite.org/malloc.html ~Eric ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
On Mon, Jun 29, 2009 at 08:10:20AM -0400, Greg Morehead scratched on the wall: > I'm looking specifically at the heap for the process I wrote. Well, that's where it would be -j > -Original Message- > From: sqlite-users-boun...@sqlite.org > [mailto:sqlite-users-boun...@sqlite.org]on Behalf Of Jay A. Kreibich > Sent: Friday, June 26, 2009 5:32 PM > To: General Discussion of SQLite Database > Subject: Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 > > > On Fri, Jun 26, 2009 at 05:07:16PM -0400, Greg Morehead scratched on the wall: > > > > If I close then reopen the database all my memory is recovered. > > > > Is this by design??? I was intending on keeping a connection open most of > > time. > > Are you sure you're not looking at the page cache? > >-j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Our opponent is an alien starship packed with atomic bombs. We have a protractor." "I'll go home and see if I can scrounge up a ruler and a piece of string." --from Anathem by Neal Stephenson ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
I'm looking specifically at the heap for the process I wrote. -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]on Behalf Of Jay A. Kreibich Sent: Friday, June 26, 2009 5:32 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 On Fri, Jun 26, 2009 at 05:07:16PM -0400, Greg Morehead scratched on the wall: > > If I close then reopen the database all my memory is recovered. > > Is this by design??? I was intending on keeping a connection open most of > time. Are you sure you're not looking at the page cache? -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Our opponent is an alien starship packed with atomic bombs. We have a protractor." "I'll go home and see if I can scrounge up a ruler and a piece of string." --from Anathem by Neal Stephenson ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
So it seems by best bet is to close and open the connection once every 5 minutes or so? -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]on Behalf Of Kees Nuyt Sent: Friday, June 26, 2009 5:31 PM To: sqlite-users@sqlite.org Subject: Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 On Fri, 26 Jun 2009 17:07:16 -0400, "Greg Morehead" <gmoreh...@premiumpower.com> wrote: > >If I close then reopen the database all my memory is recovered. > >Is this by design??? Yes, what you see is probably the page cache. >I was intending on keeping a connection open most of time. That's a good idea, for at least two reasons: - opening a connection has to parse the schema, and though it's fast code, it should be avoided. - the contents of the page cache aren't wasted, it may be re-used by subsequent statements. -- ( Kees Nuyt ) c[_] ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
On Fri, Jun 26, 2009 at 05:07:16PM -0400, Greg Morehead scratched on the wall: > > If I close then reopen the database all my memory is recovered. > > Is this by design??? I was intending on keeping a connection open most of > time. Are you sure you're not looking at the page cache? -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Our opponent is an alien starship packed with atomic bombs. We have a protractor." "I'll go home and see if I can scrounge up a ruler and a piece of string." --from Anathem by Neal Stephenson ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
On Fri, 26 Jun 2009 17:07:16 -0400, "Greg Morehead"wrote: > >If I close then reopen the database all my memory is recovered. > >Is this by design??? Yes, what you see is probably the page cache. >I was intending on keeping a connection open most of time. That's a good idea, for at least two reasons: - opening a connection has to parse the schema, and though it's fast code, it should be avoided. - the contents of the page cache aren't wasted, it may be re-used by subsequent statements. -- ( Kees Nuyt ) c[_] ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
If I close then reopen the database all my memory is recovered. Is this by design??? I was intending on keeping a connection open most of time. -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]on Behalf Of Greg Morehead Sent: Friday, June 26, 2009 4:41 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 FYI. I replaced the sqlite3_exec call with sqlite3_prepare_v2, sqlite3_step, sqlite3_finalize. Same results. -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]on Behalf Of Greg Morehead Sent: Friday, June 26, 2009 4:21 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 Based on the documentation in the link you sent I should only need to call free if there was an error message. But, since there is no harm in calling sqlite3_free on a null pointer I moved it out of the if statement. It had no impact, still leaking like faucet. -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]on Behalf Of Ribeiro, Glauber Sent: Friday, June 26, 2009 4:17 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 I took only a quick look, but it seems to me that sqlite3_free is only being called if there is an error. See http://sqlite.org/c3ref/exec.html g -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Greg Morehead Sent: Friday, June 26, 2009 2:49 PM To: sqlite-users@sqlite.org Subject: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 The extremely simple app below leaks. What am I doing wrong?? Please help. #include #include #include "stdio.h" #include "sqlite3.h" #include #define TFQ_SQL_DB_NAME "/powerblock/datalog/TFQ-test.db" #define _TABLE_NAME "sqltest" int main(int argc, char *argv[]) { char sql[1024]; char * errmsg; sqlite3* db_; int flags = SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; if (sqlite3_open_v2(TFQ_SQL_DB_NAME , _ , flags , NULL) != SQLITE_OK) { return EXIT_FAILURE; } sprintf(sql, "CREATE TABLE %s_info (col_idx, col_name, data_type, meta_type, description, grouping); " , _TABLE_NAME); int retval = sqlite3_exec(db_, sql, 0, 0, ); int idx = 1; while(retval==SQLITE_OK) { sprintf(sql, "INSERT INTO %s_info VALUES(%d, \"rowid\", \"INTEGER\", \"%s\", \"Unique Row ID\", \"_SQL\");" , _TABLE_NAME, idx++, "INTEGER" ); retval = sqlite3_exec(db_, sql, 0, 0, ); if(retval != SQLITE_OK) { printf("Recieved an sqlite failure. : Failed msg: %s", errmsg); sqlite3_free(errmsg); } else printf("Successfully inserted row idx %d\r\n", idx); usleep(5); } return EXIT_SUCCESS; } ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
FYI. I replaced the sqlite3_exec call with sqlite3_prepare_v2, sqlite3_step, sqlite3_finalize. Same results. -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]on Behalf Of Greg Morehead Sent: Friday, June 26, 2009 4:21 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 Based on the documentation in the link you sent I should only need to call free if there was an error message. But, since there is no harm in calling sqlite3_free on a null pointer I moved it out of the if statement. It had no impact, still leaking like faucet. -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]on Behalf Of Ribeiro, Glauber Sent: Friday, June 26, 2009 4:17 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 I took only a quick look, but it seems to me that sqlite3_free is only being called if there is an error. See http://sqlite.org/c3ref/exec.html g -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Greg Morehead Sent: Friday, June 26, 2009 2:49 PM To: sqlite-users@sqlite.org Subject: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 The extremely simple app below leaks. What am I doing wrong?? Please help. #include #include #include "stdio.h" #include "sqlite3.h" #include #define TFQ_SQL_DB_NAME "/powerblock/datalog/TFQ-test.db" #define _TABLE_NAME "sqltest" int main(int argc, char *argv[]) { char sql[1024]; char * errmsg; sqlite3* db_; int flags = SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; if (sqlite3_open_v2(TFQ_SQL_DB_NAME , _ , flags , NULL) != SQLITE_OK) { return EXIT_FAILURE; } sprintf(sql, "CREATE TABLE %s_info (col_idx, col_name, data_type, meta_type, description, grouping); " , _TABLE_NAME); int retval = sqlite3_exec(db_, sql, 0, 0, ); int idx = 1; while(retval==SQLITE_OK) { sprintf(sql, "INSERT INTO %s_info VALUES(%d, \"rowid\", \"INTEGER\", \"%s\", \"Unique Row ID\", \"_SQL\");" , _TABLE_NAME, idx++, "INTEGER" ); retval = sqlite3_exec(db_, sql, 0, 0, ); if(retval != SQLITE_OK) { printf("Recieved an sqlite failure. : Failed msg: %s", errmsg); sqlite3_free(errmsg); } else printf("Successfully inserted row idx %d\r\n", idx); usleep(5); } return EXIT_SUCCESS; } ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
Based on the documentation in the link you sent I should only need to call free if there was an error message. But, since there is no harm in calling sqlite3_free on a null pointer I moved it out of the if statement. It had no impact, still leaking like faucet. -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]on Behalf Of Ribeiro, Glauber Sent: Friday, June 26, 2009 4:17 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 I took only a quick look, but it seems to me that sqlite3_free is only being called if there is an error. See http://sqlite.org/c3ref/exec.html g -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Greg Morehead Sent: Friday, June 26, 2009 2:49 PM To: sqlite-users@sqlite.org Subject: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 The extremely simple app below leaks. What am I doing wrong?? Please help. #include #include #include "stdio.h" #include "sqlite3.h" #include #define TFQ_SQL_DB_NAME "/powerblock/datalog/TFQ-test.db" #define _TABLE_NAME "sqltest" int main(int argc, char *argv[]) { char sql[1024]; char * errmsg; sqlite3* db_; int flags = SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; if (sqlite3_open_v2(TFQ_SQL_DB_NAME , _ , flags , NULL) != SQLITE_OK) { return EXIT_FAILURE; } sprintf(sql, "CREATE TABLE %s_info (col_idx, col_name, data_type, meta_type, description, grouping); " , _TABLE_NAME); int retval = sqlite3_exec(db_, sql, 0, 0, ); int idx = 1; while(retval==SQLITE_OK) { sprintf(sql, "INSERT INTO %s_info VALUES(%d, \"rowid\", \"INTEGER\", \"%s\", \"Unique Row ID\", \"_SQL\");" , _TABLE_NAME, idx++, "INTEGER" ); retval = sqlite3_exec(db_, sql, 0, 0, ); if(retval != SQLITE_OK) { printf("Recieved an sqlite failure. : Failed msg: %s", errmsg); sqlite3_free(errmsg); } else printf("Successfully inserted row idx %d\r\n", idx); usleep(5); } return EXIT_SUCCESS; } ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
I'm watching the heap from the eclipse IDE which connects to the remote debugging qconn service on the target. I've included a screen shot from the last run of the code I included. This was over 1 minute period where onlky 2782 records were written! The problem is much worse on the much larger real db's I am planning on using. -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]on Behalf Of D. Richard Hipp Sent: Friday, June 26, 2009 3:58 PM To: General Discussion of SQLite Database Subject: Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 On Jun 26, 2009, at 3:49 PM, Greg Morehead wrote: > The extremely simple app below leaks. What am I doing wrong?? > Please help. How do you know it is leaking memory? How are you measuring? > > > #include > #include > #include "stdio.h" > #include "sqlite3.h" > #include > > #define TFQ_SQL_DB_NAME "/powerblock/datalog/TFQ-test.db" > #define _TABLE_NAME "sqltest" > > int main(int argc, char *argv[]) > { > char sql[1024]; > char * errmsg; > sqlite3* db_; > int flags = SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_READWRITE | > SQLITE_OPEN_CREATE; > > if (sqlite3_open_v2(TFQ_SQL_DB_NAME > , _ > , flags > , NULL) != SQLITE_OK) { > return EXIT_FAILURE; > } > > sprintf(sql, > "CREATE TABLE %s_info (col_idx, col_name, data_type, > meta_type, > description, grouping); " > , _TABLE_NAME); > > int retval = sqlite3_exec(db_, sql, 0, 0, ); > int idx = 1; > while(retval==SQLITE_OK) > { > sprintf(sql, > "INSERT INTO %s_info VALUES(%d, \"rowid\", > \"INTEGER\", \"%s\", > \"Unique Row ID\", \"_SQL\");" > , _TABLE_NAME, idx++, "INTEGER" ); > > retval = sqlite3_exec(db_, sql, 0, 0, ); > > if(retval != SQLITE_OK) { > printf("Recieved an sqlite failure. : Failed msg: %s", > errmsg); > sqlite3_free(errmsg); > } > else > printf("Successfully inserted row idx %d\r\n", idx); > > usleep(5); > } > return EXIT_SUCCESS; > } > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users D. Richard Hipp d...@hwaci.com ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
I took only a quick look, but it seems to me that sqlite3_free is only being called if there is an error. See http://sqlite.org/c3ref/exec.html g -Original Message- From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Greg Morehead Sent: Friday, June 26, 2009 2:49 PM To: sqlite-users@sqlite.org Subject: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1 The extremely simple app below leaks. What am I doing wrong?? Please help. #include #include #include "stdio.h" #include "sqlite3.h" #include #define TFQ_SQL_DB_NAME "/powerblock/datalog/TFQ-test.db" #define _TABLE_NAME "sqltest" int main(int argc, char *argv[]) { char sql[1024]; char * errmsg; sqlite3* db_; int flags = SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; if (sqlite3_open_v2(TFQ_SQL_DB_NAME , _ , flags , NULL) != SQLITE_OK) { return EXIT_FAILURE; } sprintf(sql, "CREATE TABLE %s_info (col_idx, col_name, data_type, meta_type, description, grouping); " , _TABLE_NAME); int retval = sqlite3_exec(db_, sql, 0, 0, ); int idx = 1; while(retval==SQLITE_OK) { sprintf(sql, "INSERT INTO %s_info VALUES(%d, \"rowid\", \"INTEGER\", \"%s\", \"Unique Row ID\", \"_SQL\");" , _TABLE_NAME, idx++, "INTEGER" ); retval = sqlite3_exec(db_, sql, 0, 0, ); if(retval != SQLITE_OK) { printf("Recieved an sqlite failure. : Failed msg: %s", errmsg); sqlite3_free(errmsg); } else printf("Successfully inserted row idx %d\r\n", idx); usleep(5); } return EXIT_SUCCESS; } ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
On Jun 26, 2009, at 3:49 PM, Greg Morehead wrote: > The extremely simple app below leaks. What am I doing wrong?? > Please help. How do you know it is leaking memory? How are you measuring? > > > #include > #include > #include "stdio.h" > #include "sqlite3.h" > #include > > #define TFQ_SQL_DB_NAME "/powerblock/datalog/TFQ-test.db" > #define _TABLE_NAME "sqltest" > > int main(int argc, char *argv[]) > { > char sql[1024]; > char * errmsg; > sqlite3* db_; > int flags = SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_READWRITE | > SQLITE_OPEN_CREATE; > > if (sqlite3_open_v2(TFQ_SQL_DB_NAME > , _ > , flags > , NULL) != SQLITE_OK) { > return EXIT_FAILURE; > } > > sprintf(sql, > "CREATE TABLE %s_info (col_idx, col_name, data_type, > meta_type, > description, grouping); " > , _TABLE_NAME); > > int retval = sqlite3_exec(db_, sql, 0, 0, ); > int idx = 1; > while(retval==SQLITE_OK) > { > sprintf(sql, > "INSERT INTO %s_info VALUES(%d, \"rowid\", > \"INTEGER\", \"%s\", > \"Unique Row ID\", \"_SQL\");" > , _TABLE_NAME, idx++, "INTEGER" ); > > retval = sqlite3_exec(db_, sql, 0, 0, ); > > if(retval != SQLITE_OK) { > printf("Recieved an sqlite failure. : Failed msg: %s", > errmsg); > sqlite3_free(errmsg); > } > else > printf("Successfully inserted row idx %d\r\n", idx); > > usleep(5); > } > return EXIT_SUCCESS; > } > > ___ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users D. Richard Hipp d...@hwaci.com ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Memory leak with sqlite3_exec on qnx 6.4.1
The extremely simple app below leaks. What am I doing wrong?? Please help. #include #include #include "stdio.h" #include "sqlite3.h" #include #define TFQ_SQL_DB_NAME "/powerblock/datalog/TFQ-test.db" #define _TABLE_NAME "sqltest" int main(int argc, char *argv[]) { char sql[1024]; char * errmsg; sqlite3* db_; int flags = SQLITE_OPEN_FULLMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE; if (sqlite3_open_v2(TFQ_SQL_DB_NAME , _ , flags , NULL) != SQLITE_OK) { return EXIT_FAILURE; } sprintf(sql, "CREATE TABLE %s_info (col_idx, col_name, data_type, meta_type, description, grouping); " , _TABLE_NAME); int retval = sqlite3_exec(db_, sql, 0, 0, ); int idx = 1; while(retval==SQLITE_OK) { sprintf(sql, "INSERT INTO %s_info VALUES(%d, \"rowid\", \"INTEGER\", \"%s\", \"Unique Row ID\", \"_SQL\");" , _TABLE_NAME, idx++, "INTEGER" ); retval = sqlite3_exec(db_, sql, 0, 0, ); if(retval != SQLITE_OK) { printf("Recieved an sqlite failure. : Failed msg: %s", errmsg); sqlite3_free(errmsg); } else printf("Successfully inserted row idx %d\r\n", idx); usleep(5); } return EXIT_SUCCESS; } ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users