System.Dispose

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure Dispose(var P: Pointer);

Properties

Type Visibility Source Unit Parent
procedure public System.pas System System

Description

Releases the memory allocated for a dynamic variable.

Dispose releases the memory allocated for a pointer variable allocated using System.New. For a pointer that was allocated using System.GetMem, use System.FreeMem to release the memory allocated. After a call to Dispose or FreeMem, the value of the pointer passed to it is undefined.

Note: If a pointer to unallocated memory is passed to Dispose, the behavior of the application largely depends on the target platform, as follows:

  • For Windows platforms, an EInvalidPointer is raised in applications using System.SysUtils, and a run-time error is produced for applications that do not use System.SysUtils. (FastMM, the default memory manager, can detect an invalid pointer.)
  • For Mac OS X and iOS platforms, Dispose does not raise an EInvalidPointer exception if an invalid pointer is passed to Dispose.

See Also

Code Examples