So i have been investigating further, and here are my findings so far:
We are working exclusively in virtual development machines using vmware with windows 7.
If i compile and run my test application with Delphi Seattle in our new seattle VM, there is no leak.
If i run the compiled executable in our Delphi 2010 VM, there is seems to be a leak once again. But much less than if compiled with Delphi 2010.
But.. if i compile with Delphi 2010, the application will leak in both VMs. thats a very inconsistent behaviour which is really confusing me.
Maybe its tied to what kind of drivers are being used to connect to MSSQL?
How can i maybe see or change the driver being used?
The next confusing thing is.. If i leave 2 parameter empty/null, then i still see the same behaviour as described. But once i run it out of my VM, inside my hostsystem (also Windows 7), i am getting "invalid input parameters. Check the status values for details".
But if i fill all parameters or leave one null (tried for each, doesnt matter which), it runs fine.
And finally here is the testprogram i used. .but as i said, its stripped down to most simple calls. Change the table/fields as you see fit. It does not matter if the field type is numeric, date, varchar etc.
Code: Select all
program SQLServerLeak;
{$APPTYPE CONSOLE}
uses
DBAccess,
Uni,
SQLServerUniProvider;
procedure TestIt;
var
LUniQuery: TCustomDADataSet;
LUniConnection : TUniConnection;
lidx : integer;
begin
LUniConnection := TUniConnection.Create(nil);
LUniConnection.ProviderName := 'Sql Server';
LUniConnection.Username := 'username';
LUniConnection.Password := 'password';
LUniConnection.Server := 'SQL2010SRV\MSSQLPRD';
LUniConnection.LoginPrompt := False;
LUniConnection.Connect;
LUniQuery := TUniQuery.Create(nil);
LUniQuery.Connection := LUniConnection;
for lidx := 0 to 20002 do
begin
if (lidx mod 50) = 0 then
Writeln(lidx);
LUniQuery.ParamCheck := True;
LUniQuery.SQL.Clear;
LUniQuery.SQL.Add('Select * from tblwms_lu_tara where wlut_guid = :parawlut_guid and wlut_lu=:parawlut_lu and wlut_weight_tara = :parawlut_weight_tara and wlut_description= :parawlut_description');
LUniQuery.Params[0].Value := 'Hallo2';
LUniQuery.Params[1].Value := 'Hallo2';
LUniQuery.Params[2].Value := 3;
// Uncomment the following line and the leak will disappear
// LUniQuery.Params[3].Value := '';
LUniQuery.Execute;
end;
FreeAndNil(LUniQuery);
FreeAndNil(LUniConnection);
end;
begin
try
CoInitializeEx(nil, COINIT_MULTITHREADED);
TestIt;
CoUninitialize;
except
on E: Exception do
begin
Writeln(E.ClassName, ': ', E.Message);
Readln;
end;
end;
end.