Bug #110016 max_prepared_stmt_count exceeded and memory leak - OdbcCommand / Insert
Submitted: 10 Feb 5:16 Modified: 10 Feb 7:58
Reporter: Terry Fenning Email Updates:
Status: Analyzing Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:8.0.32 OS:Windows (Win 10 Pro - Ver 22H2)
Assigned to: MySQL Verification Team CPU Architecture:x86 (64 bit odbc driver)
Tags: ODBC Memory Leak max_prepared_stmt_count

[10 Feb 5:16] Terry Fenning
Description:
Can't create more than max_prepared_stmt_count statements.
Initial issue observed with the 8.0.32 driver.  Same code works on on 5.3.13, fails on 8.0.32.

Calling '.Dispose' on the OdbcCommand object method resolves the incremental count.
However, subsequent testing reveals a memory leak(?) when run over an extended period.
Replicating this with ODBC 5.3.13 does not experience these problems.

How to repeat:
Use "n" call/long running process against the DB.
a) Greater than max_prepared_stmt_count and re memory leak, greater than 100,000  I/Os.

LogSysMsgcmd = New OdbcCommand("insert into " & DB__SYSTEM_APP_LOG & " ( " _
   					  & DB_APP_LOG_DATE_TIME & "," _
					  & DB_APP_LOG_USERNAME & ", " _
					  & DB_APP_ID & ", " _
					  & DB_APP_MSG_TYPE & ", " _
					  & DB_APP_MESSAGE & ", " _
					  & DB_APP_LOG_INIT_MSG_ID & " )" _
		& " values (" & SYSDATETIME & "," _
			  & SYSTEMUSER & "," & "?,?,?,?" & ");")

		LogSysMsgcmd.Connection = _ODBCConnection
		LogSysMsgcmd.Parameters.Add(DB_APP_ID, OdbcType.Char, 20, DB_APP_ID)
		LogSysMsgcmd.Parameters.Add(DB_APP_MSG_TYPE, OdbcType.Char, 1, DB_APP_MSG_TYPE)
		LogSysMsgcmd.Parameters.Add(DB_APP_MESSAGE, OdbcType.VarChar, DBC_APP_MESSAGE_LENGTH, DB_APP_MESSAGE)
		LogSysMsgcmd.Parameters.Add(DB_APP_LOG_INIT_MSG_ID, OdbcType.BigInt, 12, DB_APP_LOG_INIT_MSG_ID)
		LogSysMsgcmd.Parameters(DB_APP_ID).Value = AppID
		LogSysMsgcmd.Parameters(DB_APP_MSG_TYPE).Value = MsgType
		LogSysMsgcmd.Parameters(DB_APP_MESSAGE).Value = LogMsg
		LogSysMsgcmd.Parameters(DB_APP_LOG_INIT_MSG_ID).Value = InitLogMsgId

		Dim AppMsgObj As Object = LogSysMsgcmd.ExecuteNonQuery()

& optionally:-
		LogSysMsgcmd.Dispose()

Suggested fix:
"Resolved" such that the 8.0.x driver runs with the same results as the 5.3.13 driver with respect to Insert/s.