Browse Source

+ HaltOnNotReleased boolean added:defaults to false.
if set to true, and all memory is not freed,
a RTE 203 is generated.
Can only be set via HEAPTRC environment variable.

git-svn-id: trunk@5806 -

pierre 18 years ago
parent
commit
1eefed6cfe
1 changed files with 7 additions and 0 deletions
  1. 7 0
      rtl/inc/heaptrc.pp

+ 7 - 0
rtl/inc/heaptrc.pp

@@ -55,6 +55,9 @@ const
   quicktrace : boolean=true;
   quicktrace : boolean=true;
   { calls halt() on error by default !! }
   { calls halt() on error by default !! }
   HaltOnError : boolean = true;
   HaltOnError : boolean = true;
+  { Halt on exit if any memory was not freed }
+  HaltOnNotReleased : boolean = false;
+
   { set this to true if you suspect that memory
   { set this to true if you suspect that memory
     is freed several times }
     is freed several times }
 {$ifdef EXTRA}
 {$ifdef EXTRA}
@@ -1002,6 +1005,8 @@ begin
        ;
        ;
      pp:=pp^.previous;
      pp:=pp^.previous;
    end;
    end;
+  if HaltOnNotReleased and (getmem_cnt<>freemem_cnt) then
+    exitcode:=203;
 end;
 end;
 
 
 
 
@@ -1228,6 +1233,8 @@ begin
    useheaptrace:=false;
    useheaptrace:=false;
   if pos('nohalt',s)>0 then
   if pos('nohalt',s)>0 then
    haltonerror:=false;
    haltonerror:=false;
+  if pos('haltonnotreleased',s)>0 then
+   HaltOnNotReleased :=true;
   i:=pos('log=',s);
   i:=pos('log=',s);
   if i>0 then
   if i>0 then
    begin
    begin