summaryrefslogtreecommitdiff
path: root/tests/webtbs/tw14315.pp
blob: 321b910abf07ce833be52b95028e62557e23e846 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
program Project1;

{$mode objfpc}{$H+}

uses
  Classes, SysUtils;

function RandomRange(const low : longint;
                     const high : longint) : longint;
begin
  if (high < low) then
    result := high + random(low - high + 1)
  else
    Result := low + random(high - low + 1);
end;

procedure GetStats(out used: ptruint);
var
  fpcHeapStatus : TFPCHeapStatus;
begin
  fpcHeapStatus := GetFPCHeapStatus();
  used:=fpcHeapStatus.CurrHeapUsed;
  writeln(' heap status: cu=' +
          IntToStr(fpcHeapStatus.CurrHeapUsed) + ', cs=' +
          IntToStr(fpcHeapStatus.CurrHeapSize) + ', cf=' +
          IntToStr(fpcHeapStatus.CurrHeapFree) + ', mu=' +
          IntToStr(fpcHeapStatus.MaxHeapUsed) + ', ms=' +
          IntToStr(fpcHeapStatus.MaxHeapSize));
end;

var
  i : integer;
  a : array of byte;
  u1, u2: ptruint;
begin
  randomize();
  writeln('randseed: ',randseed);
  GetStats(u1);
  for i := 0 to 50 do begin
    SetLength(a, RandomRange(1024,1024*1024*15));
  end;
  SetLength(a, 0);
  GetStats(u2);
  if u1<>u2 then
    halt(1);
end.