New function of PHP gc_status() fetch the data about garbage collector. However, Java doesn’t clearly specify memory and remove this from the program code.

New function of PHP v7.3 gc_status() for garbage collector

PARAMETERS

Parameters are ‘Null’ into this function.

New function of PHP v7.3 gc_status() for garbage collector

RETURN VALUES

Following data would be the output:

  • ‘threshold’ It is for ‘num allocs’ when other automatic gc run has been scheduled
  • ‘runs’
  • ‘roots’
  • ‘collected’

Example:

<?php

// create object tree that requires gc collection

$s = new stdClass();

$s->b = [];

for ($i = 0; $i < 100000; $i++) {

    $d = new stdClass();

    $d->a = $s;

    $s->b[] = $d;

}

unset($s);

unset($d);

gc_collect_cycles();

var_dump(gc_status());

As a result below will be output.

array(4) {

  [“runs”]=>

  int(5)

  [“collected”]=>

  int(100002)

  [“threshold”]=>

  int(50001)

  [“roots”]=>

  int(0)

}

New function of PHP v7.3 gc_status() for garbage collector

TIP

As has been noted. Coder doesn’t certainly remove the memory into the program. Moreover, garbage collector searches the unnecessary garbage objects and remove them. Basically, this garbage collector was built based on two hypotheses. 

  • As can be seen majorly all the objects soon become not reachable.
  • References from the oldest objects to the latest objects only exist in small numbers.

New function of PHP v7.3 gc_status() for garbage collector

To know about the latest updates of PHP you can also visit here :

0 Shares:
1 comment
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Dix Breves Rencontres Ebook Gratuit

Pour votre bien-être et pour arriver à vos fins, rencontres gratuites – https://www.paparencontres.fr/rencontres-gratuites/ – il est indispensable de…