While tracking down our own leaks, I found that BoundsChecker believes
that we're leaking memory, handles and semaphores from the SAP ODBC
driver (sqluser74.dll, sqlod32.dll).

If I run the small program below to simply connect to a database and
disconnect, BoundsChecker reports two regular memory leaks, one for
something allocated by MapViewOfFile(), and 116 "nested leaks".  

It also reports 9 resource leaks for things allocated by
DuplicateHandle(), CreateSemaphore(), CreateFile() and TlsAlloc().

Finally, it always claims that I've leaked the SQLHENV and the SQLHDBC.

Some of these may just be BoundsChecker weirdness, and if you know of
BC settings I can change, please let me know.  But even outside of
BoundsChecker if I watch the Task Manager I see 5 handles being leaked
every time I run this little testcase.

Am I calling something out of sequence, or am I missing some calls that
would free some handles?

-Jeff

=======================================================================

#include "stdafx.h"

int main(int argc,char* argv[])
{
   SQLRETURN  nResult;
   SQLHENV    hEnvHandle;
   SQLHDBC    hDBHandle;

   nResult = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE,
&hEnvHandle);

   nResult = SQLSetEnvAttr(hEnvHandle, SQL_ATTR_ODBC_VERSION,
(SQLPOINTER) SQL_OV_ODBC3, SQL_IS_INTEGER);

   nResult = SQLAllocHandle(SQL_HANDLE_DBC, hEnvHandle, &hDBHandle);

   SQLSMALLINT  ConnInSize;
   SQLUSMALLINT DriverCompInd;
   SQLCHAR      ConnOut[1500];
   SQLSMALLINT  ConnOutMaxSize;
   SQLSMALLINT  ConnOutSize;
   SQLHWND      WinHandle;
   char         szConnect[2048];

   strcpy(szConnect, "DRIVER={SAP
DB};SERVERNODE=localhost;SERVERDB=lddtest;UID=lexadmin;PWD=lexadmin;OPTION=3");

   ConnInSize     = strlen(szConnect);
   DriverCompInd  = SQL_DRIVER_NOPROMPT;
   ConnOutSize    = 0;
   ConnOutMaxSize = 0;
   WinHandle = NULL;

   nResult = SQLDriverConnect(hDBHandle,
                              WinHandle,
                              (SQLCHAR*)szConnect,
                              ConnInSize,
                              ConnOut,
                              ConnOutMaxSize,
                              &ConnOutSize,
                              DriverCompInd);

   nResult= SQLDisconnect(hDBHandle);

   nResult = SQLFreeHandle(SQL_HANDLE_DBC, hDBHandle);
   
   nResult = SQLFreeHandle(SQL_HANDLE_ENV, hEnvHandle);
   
   return(0);
}


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to