Additional
dbCAP
AnyDAC
ThinDAC
NCOCI8
Topic: TADParam leaks with param DataType ftUnknown
TADParam leaks with param DataType ftUnknown
Posted: 2007/06/14 08:33
 
Hello AnyDAC team,

I have some problems with memory leaks in AnyDAC. For each parameter with DataType "ftUnknown" that I create for an ADQuery or that gets created automatically when assigning a SQL statement and opening the query, there's a memory leak of a TADParam and the TADParams list.

I traced the problem down to the file daADCompClient where in line 3351 the call to "Prepare" ends up in an exception if there's a parameter with DataType "ftUnknown". After this exception is raised the rest of the procedure "InternalPrepare" is not executed which causes one TADParam to leak because the parameter is copied into another object and the old one is left alone.

I solved the problem by just putting a try...finally..end block starting from line 3341 and ending in line 3362 (see attached file daADCompClient.pas). But I am not sure if this is a good idea. Could you please check this and tell me how to fix the problem in a different way if this solution is not the best one.

Thank you in advance!

Timo

Post edited by: thiago, at: 2007/06/14 08:35
Re:TADParam leaks with param DataType ftUnknown
Posted: 2007/06/14 08:39
 
Well, this forum sucks a little bit! It didn't allow to attach the file as it was too big. But it still inserted the post. So here is the file now with just the procedure that matters...

Timo
File Attachment:
File name: daADCompClient_part.pas
File size:1305 bytes
Re:TADParam leaks with param DataType ftUnknown
Posted: 2007/06/22 03:46
 
Hello

1) Thank you for reporting. Right solution will be to replace in method TADCustomCommand.InternalUnprepare:


       FParams := TADParams.Create(GetParamsOwner);



with that:


       if FParams Params then         FParams := TADParams.Create(GetParamsOwner);



2) Also, you can set FormatOptions.DefaultParamDataType to some value. Then all parameters of ftUnknown data type, will be considered as of DefaultParamDataType data type.

Regards,
Dmitry