System.FreeMem
Delphi
procedure FreeMem(var P: Pointer); overload;
procedure FreeMem(var P: Pointer; Size: NativeInt); overload;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
procedure | public | System.pas | System | System |
Description
FreeMem frees a memory block previously allocated with GetMem.
After calling FreeMem, the value of the P
parameter is undefined.
FreeMem has two overloaded procedures.
The second procedure adds an optional Size
parameter that is obsolete and only used for backward compatibility.
Attention: FreeMem is not available in C++. Instead, you can use FreeMemory.
Note: 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
- System.FreeMemory
- System.Dispose
- System.GetMem
- System.GetMemory
- System.ReallocMem
- System.ReallocMemory