[patch] memory leak in TCustomSQLQuery.Create introduced in 29183
Original Reporter info from Mantis: michael.vanham
-
Reporter name: michael van ham
Original Reporter info from Mantis: michael.vanham
- Reporter name: michael van ham
Description:
In TCustomSQLQuery.Create, FRefreshSQL:TStringList is created on line 2095, but never freed. This causes a small memory leak.
Please see attached test program demonstrating the issue, and attached patch to correct.
Steps to reproduce:
program project1;
uses
heaptrc, SQLdb, DB;
var
FQuery : TSQLQuery;
begin
FQuery := TSQLQuery.create(nil);
FQuery.Free;
end.
Additional information:
D:\test>type test.pas
program project1;
uses
heaptrc, SQLdb, DB;
var
FQuery : TSQLQuery;
begin
FQuery := TSQLQuery.create(nil);
FQuery.Free;
end.
D:\test>set path=d:\lazarus\fpc\2.6.4\bin\i386-win32
D:\test>fpc test.pas
Free Pascal Compiler version 2.6.4 [2014/10/11] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling test.pas
Linking test.exe
14 lines compiled, 2.5 sec , 426400 bytes code, 97228 bytes data
D:\test>test.exe
Heap dump by heaptrc unit
255 memory blocks allocated : 11704/12008
255 memory blocks freed : 11704/12008
0 unfreed memory blocks : 0
True heap size : 196608 (80 used in System startup)
True free heap : 196528
D:\test>set path=c:\development\fpc\bin\i386-win32
D:\test>fpc test.pas
Free Pascal Compiler version 2.7.1 [2014/12/29] for i386
Copyright (c) 1993-2014 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling test.pas
Linking test.exe
14 lines compiled, 2.6 sec, 411120 bytes code, 11716 bytes data
D:\test>test.exe
Heap dump by heaptrc unit
256 memory blocks allocated : 12130/12328
255 memory blocks freed : 12062/12256
1 unfreed memory blocks : 68
True heap size : 229376 (80 used in System startup)
True free heap : 229152
Should be : 229160
Call trace for block $016A2598 size 68
$00401693
D:\test>
Mantis conversion info:
- Mantis ID: 27220
- OS: Windows
- OS Build: 8.1
- Build: 29360
- Version: 2.7.1
- Fixed in version: 3.0.0
- Fixed in revision: 29361 (#868ba156)
- Monitored by: » michael.vanham (michael van ham)
- Target version: 3.0.0