Sign in Join
FPDoc Onlineexperiment

FreeAndNil procedure

In unit sysutils

Free object if needed, and set object reference to Nil.

Declaration

pascal
procedure FreeAndNil(constref obj: TObject)

Description

FreeAndNil will free the object in Obj and will set the reference in Obj to Nil. The reference is set to Nil first, so if an exception occurs in the destructor of the object, the reference will be Nil anyway.

Errors

Exceptions that occur during the destruction of Obj are not caught.

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