| Bug #14283 | Handle leak when Sleep() under multithread | ||
|---|---|---|---|
| Submitted: | 25 Oct 2005 7:56 | Modified: | 26 Oct 2005 21:55 |
| Reporter: | Summus Ho | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / ODBC | Severity: | S2 (Serious) |
| Version: | 3.51.11 | OS: | Windows (Win2k) |
| Assigned to: | MySQL Verification Team | CPU Architecture: | Any |
[25 Oct 2005 14:25]
MySQL Verification Team
Could you please provide the complete test case, in another words the project file *dsw or *.sln. Thanks in advance.
[26 Oct 2005 8:35]
Vasily Kishkin
Thanks for your test case. I was able to reproduce it. I attached files.
[26 Oct 2005 8:37]
Vasily Kishkin
Result with sleep
Attachment: wsleep.txt (text/plain), 4.91 KiB.
[26 Oct 2005 8:38]
Vasily Kishkin
Result without sleep
Attachment: wosleep.txt (text/plain), 15.76 KiB.
[26 Oct 2005 21:55]
MySQL Verification Team
Thank you for the feedback and test case, however I built your test case and ran it against Purify and the memory leaks reported are from your application and not due to our driver.

Description: Hi, I wrote a multithread application with odbc native code to do connection with MySQL with MyODBC. The following thread module is executed with _beginthreadex(). The handle count keep increasing rapidly. However, if I remove the Sleep(100) in the following sample. The handle count in quite stable. If I run it in single thread without Sleep(), handle is ok as well. I tested the same code with Access or MS SQL with or without Sleep(). There is no leakage. Pls advise. How to repeat: unsigned __stdcall thr_process(LPVOID argp) { int i; HENV m_hEnv; // Handle to environment HDBC m_hDBC; // Handle to database connection int n, j; m_hEnv = NULL; m_hDBC = NULL; for (i = 0; i < 100000; i++) { n = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &m_hEnv ); if( n == SQL_SUCCESS || n == SQL_SUCCESS_WITH_INFO ) { n = SQLSetEnvAttr( m_hEnv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0 ); if( n == SQL_SUCCESS || n == SQL_SUCCESS_WITH_INFO ) { n = SQLAllocHandle( SQL_HANDLE_DBC, m_hEnv, &m_hDBC ); if( n == SQL_SUCCESS || n == SQL_SUCCESS_WITH_INFO ) { SQLSetConnectOption( m_hDBC,SQL_LOGIN_TIMEOUT,5 ); n=SQLConnect( m_hDBC, ( SQLTCHAR *)"ird_prd", SQL_NTS, ( SQLTCHAR *)"ird_prd_user", SQL_NTS, ( SQLTCHAR *)"ird_prd01", SQL_NTS ); if( n == SQL_SUCCESS || n == SQL_SUCCESS_WITH_INFO ) { printf("link ok %d\n",i); } } } } if( m_hDBC != SQL_NULL_HDBC) { j = SQLDisconnect( m_hDBC ); j = SQLFreeHandle( SQL_HANDLE_DBC, m_hDBC ); } if( m_hEnv!=SQL_NULL_HENV) j = SQLFreeHandle( SQL_HANDLE_ENV, m_hEnv ); m_hDBC = NULL; m_hEnv = NULL; Sleep(100); } return 0; }