Substr.LiveMemoryBlocks Method

function LiveMemoryBlocks: NativeInt;

Process-wide: the blocks allocated (GetMem, AllocMem) minus the blocks freed (FreeMem) while the counting manager was installed.

Returns: NativeInt

Remarks:

Two readings around a region give the blocks it left allocated, on all threads.

Examples

A block taken and given back.

uses Substr;

procedure Example;
var p: Pointer;
    n: NativeInt;
begin
    InstallMemoryAllocCount;
    try
        n := LiveMemoryBlocks;
        GetMem(p, 100);
        Assert(LiveMemoryBlocks = n + 1);
        FreeMem(p);
        Assert(LiveMemoryBlocks = n);
    finally
        RemoveMemoryAllocCount;
    end;
end;