----- Original Message ----- From: "Mark Wyszomierski" <[EMAIL PROTECTED]>
To: <sqlite-users@sqlite.org>
Sent: Thursday, September 15, 2005 1:07 PM
Subject: Re: [sqlite] tracing memroy leak


Hi Dennis,
I agree with you about Send/PostMessage(). I just don't see why this is
turning into a problem for sqlite - I thought the only rule was that
database handles have to be unique to each thread. So my application posting
the message via PostMessage() has its own database handle - then the
application which receives and handles the posted message in a message
handler - has its own database handle created within the handler itself. So
everywhere it seems there is a uniqe database handle, unless I'm
misinterpreting the rules or what you described? I put down my pseudo code
to illustrate what I'm doing:
app1:
SomeThread()
{
sqlite3 *db = opendatabase();
writesomestuff();
PostMessage(my_other_app, 0, 0);
closedatabase(db);
return 0;
}
app2:
MessageHandlerInMainThread()
{
sqlite3 *db = opendatabase();
ReadDatabaseStuff(db);
closedatabase();
return 0;
}

How were the threads created? Using beginthread[ex]() or using the CreateThread API?

For beginthread() and beginthreadex() you should just return from the function.

For CreateThread(), here's an snippet from MSDN:
ExitThread is the preferred method of exiting a thread in C code. However, in C++ code, the thread is exited before any destructors can be called or any other automatic cleanup can be performed. Therefore, in C++ code, you should return from your thread function.

Robert



Reply via email to