I'm using the (newly released) Microsoft ODBC driver for Linux:
"Driver=SQL Server Native Client 11.0"
I am using the Linux tool "valgrind" on a small test program that
just tries to establish a database connection and then disconnects,
SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &h_env);
SQLSetEnvAttr(h_env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER*)SQL_OV_ODBC3, 0);
SQLAllocHandle(SQL_HANDLE_DBC, h_env, &h_dbc);
SQLDriverConnect(h_dbc, NULL, ...
When the call to SQLDriverConnect is successful, valgrind reports
that no memory has been leaked.
When the call to SQLDriverConnect fails for whatever reason
(for example: database offline, host down, etc...), each call
to SQLDriverConnect leaks 1034 bytes of memory.
I have tried invoking SQLGetDiagRec() to free the memory but that didn't help.
Any suggestions on how to avoid the memory leak?