HomeMenu
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:

  • running
  • protected
  • full
  • runs
  • collected
  • threshold
  • buffer_size
  • roots
  • application_time
  • collector_time
  • destructor_time
  • free_time

Examples

1 · void

<?

$return = gc_status();

print_r($return);
Array
(
    [running] => 
    [protected] => 
    [full] => 
    [runs] => 0
    [collected] => 0
    [threshold] => 10001
    [buffer_size] => 16384
    [roots] => 0
    [application_time] => 0.00031926
    [collector_time] => 0
    [destructor_time] => 0
    [free_time] => 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();

print_r($return);
Array
(
    [running] => 
    [protected] => 
    [full] => 
    [runs] => 5
    [collected] => 100002
    [threshold] => 50001
    [buffer_size] => 131072
    [roots] => 0
    [application_time] => 0.091236545
    [collector_time] => 0.04983155
    [destructor_time] => 0
    [free_time] => 0.007071822
)