[fpc-pascal] Ansistring not being freed on Halt(1)

Brad Campbell brad at wasp.net.au
Mon Sep 29 11:19:26 CEST 2008

I'm chasing an issue with a program I have that is leaving an Ansistring unfreed on exit. It exists 
cleanly without using halt(), but this is the the only way I've managed to reproduce it.

Should Halt() leave memory unfreed?

It is only reproducible if I use ExtractFileName or ExtractFileExt.. (which is what the block trace 
points to in my program also)

This is the 2.2 Fixes svn branch as of 26/9/2008.

Program TestAnsi;
{$mode objfpc}{$H+}

Uses SysUtils;

	T1, T2 : String;
T1 := '123456789.fred';
T2 := ExtractFileName(T1);

brad at bklaptop2:~/temp$ fpc -gh -gl atest.pas
Free Pascal Compiler version 2.2.3 [2008/09/26] for i386
Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Linux for i386
Compiling atest.pas
Linking atest
16 lines compiled, 0.3 sec
brad at bklaptop2:~/temp$ ./atest
Heap dump by heaptrc unit
7 memory blocks allocated : 78/96
6 memory blocks freed     : 55/72
1 unfreed memory blocks : 23
True heap size : 65536
True free heap : 65440
Should be : 65456
Call trace for block $B7F69048 size 23
   $0804F29F  NEWANSISTRING,  line 64 of /home/brad/devel/fpc/svn/fixes/fpc/rtl/inc/astrings.inc
   $0806392F  EXTRACTFILENAME,  line 98 of 
   $080480D9  main,  line 10 of atest.pas
   $0807B187  _FPC_PROC_START,  line 72 of ./i386/si_prc.inc

Dolphins are so intelligent that within a few weeks they can
train Americans to stand at the edge of the pool and throw them

More information about the fpc-pascal mailing list