Code: Pascal [Select] Querry := TZReadOnlyQuery.Create(nil); with Querry do begin... Result := Fields;... Free; end;
It seems to me it's true. The solution for example:http://stackoverflow.com/questions/16846686/memory-leaks-when-returning-tfields-from-a-function
And the way I call it:Code: Pascal [Select]var database: tmydb; tempresult: TFields;begin database:= tmydb.Create; tempresult:=database.query('SELECT * FROM testtable;').Fields; showmessage('Items found in testtable: ' + inttostr(tempresult.Count)); database.free;end;
Good point molly, I recompile using -gh and yup memory leak.
... but if I have to choice between using unnecessary memory or a memory leak, I choice the unnecessary memory
ps: Big thank you for informing me about heaptrc. I now have to recompile bunch of my tools and I have the feeling few of them will make me cry
Thank you titya. Work like a charme.
My code can look complicate when you don't know what I am aiming for. 3 softwares will use my dbclass.pas.