home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
vp21beta.zip
/
LEXMPSRC.RAR
/
HEAP.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
2000-08-15
|
1KB
|
56 lines
{█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█}
{█ █}
{█ Virtual Pascal for Linux █}
{█ Test example for heap functions █}
{█ ─────────────────────────────────────────────────█}
{█ Copyright (C) 1999 Joerg Pleumann █}
{█ █}
{▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀}
program Heap;
uses
VpSysLow;
const Max = 4096;
var
P: array[1..Max] of Pointer;
X, I: LongInt;
begin
WriteLn('Heap usage is ', AllocMemSize, ' bytes, free memory is ', MemAvail, ' bytes.');
WriteLn;
WriteLn('Allocating ', Max, ' blocks of memory (press <Enter>).');
ReadLn;
for I := 1 to Max do
begin
X := 1 + Random(16384);
GetMem(P[I], X);
FillChar(P[I]^, X, $FF);
Write('.');
end;
WriteLn;
WriteLn('Heap usage is ', AllocMemSize, ' bytes, free memory is ', MemAvail, ' bytes.');
WriteLn;
WriteLn('De-allocating ', Max, ' blocks of memory (press <Enter>).');
ReadLn;
for I := 1 to Max do
begin
FreeMem(P[I]);
Write('.');
end;
WriteLn;
WriteLn('Heap usage is ', AllocMemSize, ' bytes, free memory is ', MemAvail, ' bytes.');
WriteLn;
WriteLn('Terminating (press <Enter>).');
ReadLn;
end.