总有人间一两风,填我十万八千梦

PHP gc_status 用法 手册 | 示例代码

PHP开发手册 归档 332℃ 0评论

gc_status

(PHP 7 >= 7.3.0)

gc_statusGets information about the garbage collector

说明

gc_status ( void ) : array

Gets information about the current state of the garbage collector.

参数

此函数没有参数。

返回值

Returns an associative array with the following elements:

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

范例

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());

以上例程的输出类似于:

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

用户贡献的笔记

There are no user contributed notes for this page.

转载请注明:悠然品鉴 » PHP gc_status 用法 手册 | 示例代码

喜欢 (0)or分享 (0)
发表我的评论
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址