[fpc-devel] Memory leak: bug ot as designed?
Bart
bartjunk64 at gmail.com
Tue Mar 28 22:39:53 CEST 2023
Hi,
The following program gives a memory leak:
===
program test;
{$mode objfpc}
{$h+}
uses
Classes;
var
SL: TStringList;
procedure Foo;
const
S: String = '';
begin
S := SL.Text; // << this is line 13
end;
begin
SL := TStringList.Create;
SL.Add('1');
Foo;
SL.Free;
end.
===
C:\Users\Bart\LazarusProjecten\ConsoleProjecten>fpc test.pas -gl -gh
Free Pascal Compiler version 3.3.1 [2022/10/11] for i386
Copyright (c) 1993-2022 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling test.pas
test.pas(11,3) Note: Local variable "S" is assigned but never used
Linking test.exe
21 lines compiled, 0.3 sec, 170976 bytes code, 7332 bytes data
1 note(s) issued
C:\Users\Bart\LazarusProjecten\ConsoleProjecten>test
Heap dump by heaptrc unit of
"C:\Users\Bart\LazarusProjecten\ConsoleProjecten\test.exe"
117 memory blocks allocated : 2859/3152
116 memory blocks freed : 2843/3136
1 unfreed memory blocks : 16
True heap size : 294912 (272 used in System startup)
True free heap : 294512
Should be : 294528
Call trace for block $016E93B0 size 16
$00401787 FOO, line 13 of test.pas
$004017E9 main, line 18 of test.pas
Is that a bug, or a user error?
--
Bart
More information about the fpc-devel
mailing list