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:
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:
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
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
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
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,
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
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
8 matches
Mail list logo