(PHP 7 >= 7.3.0)
gc_status — Gets information about the garbage collector
gc_status ( ) : array
Gets information about the current state of the garbage collector.
This function has no parameters.
Returns an associative array with the following elements:
"runs"
"collected"
"threshold"
"roots"
Example #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());
The above example will output something similar to:
© 1997–2020 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/function.gc-status.php