Script API - v26.70.26
    Preparing search index...
    import { collectRuntimeStats } from "@minecraft/debug-utilities";
    import { Player, system } from "@minecraft/server";

    // Run `/scriptevent example:getstats` in chat to print script runtime memory stats.
    system.afterEvents.scriptEventReceive.subscribe(({ id, sourceEntity }) => {
    if (id !== "example:getstats" || !(sourceEntity instanceof Player)) return;

    const stats = collectRuntimeStats();
    sourceEntity.sendMessage(
    `Memory used: ${stats.memoryUsedSize} / ${stats.memoryAllocatedSize} bytes (objects: ${stats.objectCount})`,
    );
    });
    interface RuntimeStats {
        arrayCount: number;
        atomCount: number;
        atomSize: number;
        fastArrayCount: number;
        fastArrayElementCount: number;
        functionCodeSize: number;
        functionCount: number;
        functionLineCount: number;
        functionSize: number;
        memoryAllocatedCount: number;
        memoryAllocatedLimit: number;
        memoryAllocatedSize: number;
        memoryUsedCount: number;
        memoryUsedSize: number;
        objectCount: number;
        objectSize: number;
        propertyCount: number;
        propertySize: number;
        stringCount: number;
        stringSize: number;
    }
    Index
    arrayCount: number
    atomCount: number
    atomSize: number
    fastArrayCount: number
    fastArrayElementCount: number
    functionCodeSize: number
    functionCount: number
    functionLineCount: number
    functionSize: number
    memoryAllocatedCount: number
    memoryAllocatedLimit: number
    memoryAllocatedSize: number
    memoryUsedCount: number
    memoryUsedSize: number
    objectCount: number
    objectSize: number
    propertyCount: number
    propertySize: number
    stringCount: number
    stringSize: number