memory_get_usage

Supported Versions: PHP 4 >= 4.3.2, PHP 5, PHP 7, PHP 8
Returns the amount of memory allocated to PHP
<?php memory_get_usage(bool $real_usage = false): int
<?php });



Loop::addPeriodicTimer(5, function () {

    $memory = memory_get_usage() / 1024;

    $formatted = number_format($memory, 3).'K';

    echo "Current memory usage: {$formatted}\n";

});
<?php });



Loop::addPeriodicTimer($r, function () use (&$runs) {

    $kmem = round(memory_get_usage() / 1024);

    $kmemReal = round(memory_get_usage(true) / 1024);

    echo "Runs:\t\t\t$runs\n";

    echo "Memory (internal):\t$kmem KiB\n";
<?php Loop::addPeriodicTimer($r, function () use (&$runs) {

    $kmem = round(memory_get_usage() / 1024);

    $kmemReal = round(memory_get_usage(true) / 1024);

    echo "Runs:\t\t\t$runs\n";

    echo "Memory (internal):\t$kmem KiB\n";

    echo "Memory (real):\t\t$kmemReal KiB\n";