System.TMemoryManagerEx

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

  TMemoryManagerEx = record
    {The basic (required) memory manager functionality}
    GetMem: function(Size: NativeInt): Pointer;
    FreeMem: function(P: Pointer): Integer;
    ReallocMem: function(P: Pointer; Size: NativeInt): Pointer;
    {Extended (optional) functionality.}
    AllocMem: function(Size: NativeInt): Pointer;
    RegisterExpectedMemoryLeak: function(P: Pointer): Boolean;
    UnregisterExpectedMemoryLeak: function(P: Pointer): Boolean;
  end;

C++

struct DECLSPEC_DRECORD TMemoryManagerEx
{
public:
    void * __fastcall (*GetMem)(NativeInt Size);
    int __fastcall (*FreeMem)(void * P);
    void * __fastcall (*ReallocMem)(void * P, NativeInt Size);
    void * __fastcall (*AllocMem)(NativeInt Size);
    bool __fastcall (*RegisterExpectedMemoryLeak)(void * P);
    bool __fastcall (*UnregisterExpectedMemoryLeak)(void * P);
};

Properties

Type Visibility Source Unit Parent
record
struct
public
System.pas
System.hpp
System System

Description

TMemoryManagerEx defines extended memory block entry points.

The TMemoryManagerEx type is used by the GetMemoryManager and SetMemoryManager procedures. It defines the routines that allocate and free memory.

The following table lists the fields of this type and their meanings.



Field Meaning

GetMem

Specifies a function that allocates the given number of bytes and returns a pointer to the newly allocated block, as invoked by the GetMemory routine. The Size parameter passed to the GetMem function will never be zero. If the GetMem function cannot allocate a block of the given size, it should return nil (Delphi) or NULL (C++).

FreeMem

Specifies a function that deallocates the given block. The pointer parameter passed to the FreeMem function will never be nil (Delphi) or NULL (C++). If the FreeMem function successfully deallocates the given block, it should return zero. Otherwise, it should return a nonzero value.

ReallocMem

Specifies a function that reallocates the given block to the given new size. The pointer parameter passed to the ReallocMem function will never be nil (Delphi) or NULL (C++), and the Size parameter will never be zero. The ReallocMem function must reallocate the given block to the given new size, possibly moving the block if it cannot be resized in place. Any existing contents of the block must be preserved, but newly allocated space can be uninitialized. The ReallocMem function must return a pointer to the reallocated block, or nil (Delphi) or NULL (C++) if the block cannot be reallocated.

AllocMem

Specifies a function that allocates the given number of bytes and returns a pointer to the newly allocated block, as invoked by the AllocMem routine.

RegisterExpectedMemoryLeak

Specifies a function that registers a memory location that an application has allocated and does not expect to free, as invoked by the RegisterExpectedMemoryLeak routine.

UnregisterExpectedMemoryLeak

Specifies a function that removes a memory location from the Memory Manager's list of expected memory leaks, as invoked by the UnregisterExpectedMemoryLeak routine.



See Also

Code Examples