gc_status

(PHP 7 >= 7.3.0)

gc_statusGets information about the garbage collector

Descrierea

gc_status ( ) : array

Gets information about the current state of the garbage collector.

Parametri

Această funcție nu are parametri.

Valorile întoarse

Returns an associative array with the following elements:

  • "runs"
  • "collected"
  • "threshold"
  • "roots"

Exemple

Example #1 gc_status() Usage

<?php

// create object tree that needs gc collection
$a = new stdClass();
$a->= [];
for (
$i 0$i 100000$i++) {
    
$b = new stdClass();
    
$b->$a;
    
$a->b[] = $b;
}
unset(
$a);
unset(
$b);
gc_collect_cycles();

var_dump(gc_status());

Exemplul de mai sus va afișa ceva similar cu:

array(4) {
  ["runs"]=>
  int(5)
  ["collected"]=>
  int(100002)
  ["threshold"]=>
  int(50001)
  ["roots"]=>
  int(0)
}

A se vedea și

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top