Freemem

Declaration:
Procedure FreeMem(Var p:pointer[;Size:Longint]);
Description:
FreeMem releases the memory reserved by a call to GetMem (601). The (optional) Size parameter is ignored, since the object pascal version of GetMem stores the amount of memory that was requested.

Be sure not to release memory that was not obtained with the Getmem call in Objpas. Normally, this should not happen, since objpas changes the default memory manager to it’s own memory manager.

Errors:
None.
See also:
Freemem (504), GetMem (601), Getmem (506)

Listing: refex/ex89.pp


Program Example89;

{ Program to demonstrate the FreeMem function. }
{$Mode Delphi}

Var P : Pointer;

begin
  Writeln ('Memory before : ',Memavail);
  GetMem(P,10000);
  FreeMem(P);
  Writeln ('Memory after  : ',Memavail);
end.