Sign in Join
FPDoc Onlineexperiment

Freemem procedure

In unit System

Release allocated memory.

Declaration

pascal
procedure Freemem(p: pointer; Size: PtrUInt)

Description

Freemem releases the memory occupied by the pointer P, of size Count (in bytes), and returns it to the heap. P should point to the memory allocated to a dynamic variable.

Errors

An error will occur when P doesn't point to the heap.

See also

Example: ex28

pascal
Program Example28;

{ Program to demonstrate the FreeMem and GetMem functions. }

Var P : Pointer;
    MM : Longint;

begin
  { Get memory for P }
  GetMem (P,80);
  FillChar (P^,80,' ');
  FreeMem (P,80);
end.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.