gc_status

Gets information about the garbage collector

Syntax

gc_status(): array

Return

Returns an associative array with the following elements: "runs" "collected" "threshold" "roots"

Examples

1

<?

$return = gc_status();

var_export($return);

?>
array (
  'runs' => 0,
  'collected' => 0,
  'threshold' => 10001,
  'roots' => 0,
)

2

<?

$a = new stdClass();
$a->b = [];

for($i = 0; $i < 100000; ++$i)
{
    $b = new stdClass();
    $b->a = $a;

    $a->b[] = $b;
}

unset($a);
unset($b);
gc_collect_cycles();

$return = gc_status();

var_export($return);

?>
array (
  'runs' => 5,
  'collected' => 100002,
  'threshold' => 50001,
  'roots' => 0,
)
HomeMenu