Substr.CheckMemoryAllocCount Method

function CheckMemoryAllocCount: NativeInt;

The calling thread's heap calls - GetMem, AllocMem, ReallocMem and FreeMem - since its last MarkMemoryAllocCount, or since the thread started if it never set one.

Returns: NativeInt

Remarks:

Calls are counted only while the counting manager is installed (InstallMemoryAllocCount).

Examples

A short text stays inside the variable: no heap call.

uses Substr;

procedure Example;
var s: Substring;
begin
    InstallMemoryAllocCount;
    try
        MarkMemoryAllocCount;
        s := Substring('short text');
        s.Append(', still inside');
        Assert(CheckMemoryAllocCount = 0);
    finally
        RemoveMemoryAllocCount;
    end;
    Assert(s = 'short text, still inside');
end;