Memory Leak with SQLQuery and C++ Builder 2006
Posted: Sun 17 Jun 2007 22:31
We are using the latest CRLabs dbExpress Driver 3.20.5 under BDS2006 C++ Builder. In our application we are using TSQLConnection and TSQLQuery. Database Server = MySQL 5.0.41.
I have noticed, that there is a memory leak when you frequently open and close a simple SQLQuery. The memory increases every second, until the system goes out of memory
Our example:
SQLConnection = new TSQLConnection(NULL);
SQLConnection->ConnectionName = "MySQL Direct by Core Lab";
SQLConnection->DriverName = "MySQL Direct by Core Lab";
SQLConnection->GetDriverFunc = "getSQLDriverMySQLDirect";
SQLConnection->LibraryName = "dbexpmda30.dll";
SQLConnection->KeepConnection = true;
SQLConnection->LoginPrompt = False;
SQLConnection->Params->Add("BlobSize=-1");
SQLConnection->Params->Add("HostName="+AnsiString(mysql_host));
SQLConnection->Params->Add("DataBase="+AnsiString(mysql_db));
SQLConnection->Params->Add("DriverName=MySQL Direct by Core Lab");
SQLConnection->Params->Add("User_Name="+AnsiString(mysql_user));
SQLConnection->Params->Add("Password="+AnsiString(mysql_pass));
SQLConnection->Params->Add("FetchAll=True");
SQLConnection->Params->Add("EnableBoolean=False");
SQLConnection->VendorLib="not used";
SQLConnection->Connected=true;
SQLQuery = new TSQLQuery(NULL);
SQLQuery->SQLConnection = SQLConnection;
while(beenden==false)
{
SQLQuery->Active=false;
SQLQuery->SQL->Clear();
SQLQuery->SQL->Add("SELECT * FROM DEVICES");
SQLQuery->Active=true;
Sleep(1000);
}
What could be wrong here?
I have noticed, that there is a memory leak when you frequently open and close a simple SQLQuery. The memory increases every second, until the system goes out of memory
Our example:
SQLConnection = new TSQLConnection(NULL);
SQLConnection->ConnectionName = "MySQL Direct by Core Lab";
SQLConnection->DriverName = "MySQL Direct by Core Lab";
SQLConnection->GetDriverFunc = "getSQLDriverMySQLDirect";
SQLConnection->LibraryName = "dbexpmda30.dll";
SQLConnection->KeepConnection = true;
SQLConnection->LoginPrompt = False;
SQLConnection->Params->Add("BlobSize=-1");
SQLConnection->Params->Add("HostName="+AnsiString(mysql_host));
SQLConnection->Params->Add("DataBase="+AnsiString(mysql_db));
SQLConnection->Params->Add("DriverName=MySQL Direct by Core Lab");
SQLConnection->Params->Add("User_Name="+AnsiString(mysql_user));
SQLConnection->Params->Add("Password="+AnsiString(mysql_pass));
SQLConnection->Params->Add("FetchAll=True");
SQLConnection->Params->Add("EnableBoolean=False");
SQLConnection->VendorLib="not used";
SQLConnection->Connected=true;
SQLQuery = new TSQLQuery(NULL);
SQLQuery->SQLConnection = SQLConnection;
while(beenden==false)
{
SQLQuery->Active=false;
SQLQuery->SQL->Clear();
SQLQuery->SQL->Add("SELECT * FROM DEVICES");
SQLQuery->Active=true;
Sleep(1000);
}
What could be wrong here?