gc_status
(PHP 7 >= 7.3.0, PHP 8)
gc_status — Gets information about the garbage collector
Beschreibung
Gets information about the current state of the garbage collector.
Parameter-Liste
Diese Funktion besitzt keine Parameter.
Rückgabewerte
Returns an associative array with the following elements:
-
"runs" -
"collected" -
"threshold" -
"roots"
Beispiele
Beispiel #1 gc_status() Usage
<?php
// create object tree that needs gc collection
$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();
var_dump(gc_status());
Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:
array(4) {
["runs"]=>
int(5)
["collected"]=>
int(100002)
["threshold"]=>
int(50001)
["roots"]=>
int(0)
}

