Added num_roots to gc_status

This commit is contained in:
Xinchen Hui 2018-06-13 16:41:51 +08:00
parent e788e8261e
commit 9465ec4673
4 changed files with 11 additions and 3 deletions

View File

@ -4,27 +4,31 @@ GC 037: gc_status()
zend.enable_gc = 1
--FILE--
<?php
var_dump(gc_status());
$a = array();
$a[] =& $a;
unset($a);
var_dump(gc_status());
gc_collect_cycles();
gc_collect_cycles();
var_dump(gc_status());
--EXPECT--
array(3) {
array(4) {
["runs"]=>
int(0)
["collected"]=>
int(0)
["threshold"]=>
int(10001)
["roots"]=>
int(1)
}
array(3) {
array(4) {
["runs"]=>
int(1)
["collected"]=>
int(1)
["threshold"]=>
int(10001)
["roots"]=>
int(0)
}

View File

@ -401,7 +401,9 @@ ZEND_FUNCTION(gc_status)
add_assoc_long_ex(return_value, "runs", sizeof("runs")-1, (long)status.runs);
add_assoc_long_ex(return_value, "collected", sizeof("collected")-1, (long)status.collected);
add_assoc_long_ex(return_value, "threshold", sizeof("threshold")-1, (long)status.threshold);
add_assoc_long_ex(return_value, "roots", sizeof("roots")-1, (long)status.num_roots);
}
/* }}} */
/* {{{ proto int func_num_args(void)
Get the number of arguments that were passed to the function */

View File

@ -1447,6 +1447,7 @@ ZEND_API void zend_gc_get_status(zend_gc_status *status)
status->runs = GC_G(gc_runs);
status->collected = GC_G(collected);
status->threshold = GC_G(gc_threshold);
status->num_roots = GC_G(num_roots);
}
/*

View File

@ -28,6 +28,7 @@ typedef struct _zend_gc_status {
uint32_t runs;
uint32_t collected;
uint32_t threshold;
uint32_t num_roots;
} zend_gc_status;
ZEND_API extern int (*gc_collect_cycles)(void);