TMyQuery->Execute() creates too many threads
Posted: Fri 05 May 2006 18:11
I am having a strange problem with an SQL INSERT command. I'm inserting records using TMyQuery and for some reason a thread is being created for each insert but it seems that CloseHandle is not getting called to release the thread.
This can be seen by running SysInternals Process Explorer and looking at the handles in use. Normally only 3 threads run but with this problem a thread is created for every insert. This uses up resources and after a while MySQL will drop the connection and stop responding. If I exit my app and wait a while I can continue.
I am using BDS 2006 and MySQL 4.1.18 on XP Pro SP2. The odd thing about this is that it happens only on my laptop and not on my desktop. I am also seeing it on computers where we deploy the app. Using either the direct connect or libmySQL.dll causes the problem.
I did a stack trace to see where CreateThread was being called from. Here is the partial stack under libmySQL.dll:
TMySQLRecordset::ExecCommand
libmySQL.dll
kernel32.CreateThread
This is the stack using the direct connection:
TMySQLRecordset::ExecCommand
TMySQLConnection::Disconnect+0x14
TMySqlSession::Close+0x28
TMySqlVioTcp::Close
kernel32.CreateThread
This may be a MySQL or Windows problem, but I'm asking for help here because someone might know from prior experience what is happening. I have yet to try this on an older V3 MySQL.
James
This can be seen by running SysInternals Process Explorer and looking at the handles in use. Normally only 3 threads run but with this problem a thread is created for every insert. This uses up resources and after a while MySQL will drop the connection and stop responding. If I exit my app and wait a while I can continue.
I am using BDS 2006 and MySQL 4.1.18 on XP Pro SP2. The odd thing about this is that it happens only on my laptop and not on my desktop. I am also seeing it on computers where we deploy the app. Using either the direct connect or libmySQL.dll causes the problem.
I did a stack trace to see where CreateThread was being called from. Here is the partial stack under libmySQL.dll:
TMySQLRecordset::ExecCommand
libmySQL.dll
kernel32.CreateThread
This is the stack using the direct connection:
TMySQLRecordset::ExecCommand
TMySQLConnection::Disconnect+0x14
TMySqlSession::Close+0x28
TMySqlVioTcp::Close
kernel32.CreateThread
This may be a MySQL or Windows problem, but I'm asking for help here because someone might know from prior experience what is happening. I have yet to try this on an older V3 MySQL.
James