Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

gc_status

Description

The gc_status of Options / Information for PHP 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 (
  'running' => false,
  'protected' => false,
  'full' => false,
  'runs' => 0,
  'collected' => 0,
  'threshold' => 10001,
  'buffer_size' => 16384,
  'roots' => 0,
  'application_time' => 0.000332169,
  'collector_time' => 0.0,
  'destructor_time' => 0.0,
  'free_time' => 0.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 (
  'running' => false,
  'protected' => false,
  'full' => false,
  'runs' => 5,
  'collected' => 100002,
  'threshold' => 50001,
  'buffer_size' => 131072,
  'roots' => 0,
  'application_time' => 0.080490197,
  'collector_time' => 0.047619688,
  'destructor_time' => 0.0,
  'free_time' => 0.011712258,
)
HomeMenu