Show: Delphi C++
Display Preferences

System.FreeMem

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure FreeMem(var P: Pointer; [ Size: Integer]); overload;
procedure FreeMem(var P: Pointer; [ Size: Integer]); overload;

Properties

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

Description

FreeMem frees a memory block previously allocated with GetMem.

Use this procedure to dispose of a memory block obtained with GetMem.

The Size parameter specifies the size, in bytes, of the dynamic variable to dispose of; if specified, it must be exactly the number of bytes previously allocated to that variable by GetMem.

After calling this procedure, the value of the P parameter is undefined.

Notes:

  • FreeMem is not available in C++. In C++ you can use FreeMemory.
  • If a pointer to unallocated memory is passed to FreeMem, 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 OS X and iOS platforms, FreeMem does not raise an EInvalidPointer exception if an invalid pointer is passed to Dispose.

See Also

Code Examples

Personal tools
In Other Languages
Previous Versions
Assistance