Re: [sqlite] Is there any memory leak in the code while being busy?

2010-04-24 Thread Black, Michael (IS)
Well your test code has no leak with the free added -- so you need to post better test code to demonstrate your leak. Otherwise the suspicion would be with YOUR code. Michael D. Black Senior Scientist Northrop Grumman Mission Systems From:

Re: [sqlite] Is there any memory leak in the code while being busy?

2010-04-23 Thread liubin liu
the code's test result in my first post is : pthread2: prepare: 0, p_stmt: 0xb6a00de0, errmsg: not an error pthread2: step: 5, p_stmt: 0xb6a00de0, errmsg: database is locked pthread2: finalize: 5, p_stmt: 0xb6a00de0, errmsg: database is locked pthread2: finalize: 21, p_stmt:

Re: [sqlite] Is there any memory leak in the code while being busy?

2010-04-23 Thread liubin liu
Thanks :) But in my real code, the sqlite3_free(sql) is in the right place. So I think that there are other reasons causing the leak. Black, Michael (IS) wrote: > > You need to sqlite3_free(sql) after you use the sql from your > sqlite3_mprintf(). > > sql = sqlite3_mprintf

Re: [sqlite] Is there any memory leak in the code while being busy?

2010-04-23 Thread Black, Michael (IS)
You need to sqlite3_free(sql) after you use the sql from your sqlite3_mprintf(). sql = sqlite3_mprintf (sql_f, i); ret = sqlite3_prepare_v2 (db1, sql, -1, _stmt, NULL); sqlite3_free(sql); Michael D. Black Senior Scientist Northrop Grumman Mission Systems

Re: [sqlite] Is there any memory leak in the code while being busy?

2010-04-23 Thread Simon Slavin
On 23 Apr 2010, at 1:16pm, liubin liu wrote: > But I test the routine of sqlite3_prepare_v2() + sqlite3_step() + > sqlite3_finalize() in my real code. > > And the test result say when sqlite3_step() is shadowed, the leak is zero. > When doing the sqlite3_step(), the leak is about 1k byte. And

Re: [sqlite] Is there any memory leak in the code while being busy?

2010-04-23 Thread liubin liu
sorry for multi-send the message. I just test the code again. And sqlite3_finalize() may free the memory. I'm wrong in the first post. But I test the routine of sqlite3_prepare_v2() + sqlite3_step() + sqlite3_finalize() in my real code. And the test result say when sqlite3_step() is shadowed,

Re: [sqlite] Is there any memory leak in the code while being busy?

2010-04-23 Thread Marcus Grimm
it is not necessary to send your question multible times... ;) to answer: what makes you think that sqlite3_finalize can't free the prepared statement ? liubin liu wrote: > Is there any memory leak in the code? > > Below is the code. Is there any memory leak in the pthread2? > > While

[sqlite] Is there any memory leak in the code while being busy?

2010-04-23 Thread liubin liu
Is there any memory leak in the code? Below is the code. Is there any memory leak in the pthread2? While pthread1 is using test.db exclusively, the sqlite3_prepare_v2() of pthread2 still prepares the p_stmt pointer to a piece of memory malloced by sqlite3_preapare_v2(). And then the