Mark Wyszomierski wrote:

I traced this error down a bit, it only appears when using windows' PostMessage() to communicate between applications. Both applications have their own database handles for sure. When one app gets some data, it simply uses PostMessage() to inform the other app that some data has been received. It is at this point that if I try accessing the database in this message handler, the memory leak occurrs. I even took the additional precaution of creating an entirely new database handle inside the message handler itself. If I replace PostMessage() with SendMessage(), no leak occurrs. However, replacing PostMessage() with SendMessage() would be a huge penalty. Any ideas why there is a problem here?
Thanks,
Mark
Unless I'm wrong (he he... tha can happen):

PostMessage simply inserts the "MSG" into the target thread's message queue. The target thread's message pump needs to consume that message and dispatch it. Remember, message queues are owned by threads, not windows. PostMessage is asynchronous.

SendMessage actually dispatches the message to the target window handler, but inside the CALLERs thread context. SendMessage blocks until the call is completed. The target message handler must be reentrant for this to work.


Reply via email to