uTools-Manuals/docs/php/gc_status.html
2019-04-28 19:00:34 +08:00

106 lines
5.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Gets information about the garbage collector</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.gc-status" class="refentry">
<div class="refnamediv">
<h1 class="refname">gc_status</h1>
<p class="verinfo">(PHP 7 &gt;= 7.3.0)</p><p class="refpurpose"><span class="refname">gc_status</span> &mdash; <span class="dc-title">Gets information about the garbage collector</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.gc-status-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>gc_status</strong></span>
( <span class="methodparam">void</span>
) : <span class="type">array</span></div>
<p class="para rdfs-comment">
Gets information about the current state of the garbage collector.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.gc-status-parameters">
<h3 class="title">参数</h3>
<p class="para">此函数没有参数。</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.gc-status-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
Returns an associative array with the following elements:
<ul class="itemizedlist">
<li class="listitem">
<span class="simpara">
<em>&quot;runs&quot;</em>
</span>
</li>
<li class="listitem">
<span class="simpara">
<em>&quot;collected&quot;</em>
</span>
</li>
<li class="listitem">
<span class="simpara">
<em>&quot;threshold&quot;</em>
</span>
</li>
<li class="listitem">
<span class="simpara">
<em>&quot;roots&quot;</em>
</span>
</li>
</ul>
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.gc-status-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-494">
<p><strong>Example #1 <span class="function"><strong>gc_status()</strong></span> Usage</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;create&nbsp;object&nbsp;tree&nbsp;that&nbsp;needs&nbsp;gc&nbsp;collection<br /></span><span style="color: #0000BB">$a&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">stdClass</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$a</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">b&nbsp;</span><span style="color: #007700">=&nbsp;[];<br />for&nbsp;(</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">100000</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$b&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">stdClass</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$b</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">a&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$a</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$a</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">b</span><span style="color: #007700">[]&nbsp;=&nbsp;</span><span style="color: #0000BB">$b</span><span style="color: #007700">;<br />}<br />unset(</span><span style="color: #0000BB">$a</span><span style="color: #007700">);<br />unset(</span><span style="color: #0000BB">$b</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">gc_collect_cycles</span><span style="color: #007700">();<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">gc_status</span><span style="color: #007700">());</span>
</span>
</pre></div>
</div>
<div class="example-contents"><p>以上例程的输出类似于:</p></div>
<div class="example-contents screen">
<div class="cdata"><pre>
array(4) {
[&quot;runs&quot;]=&gt;
int(5)
[&quot;collected&quot;]=&gt;
int(100002)
[&quot;threshold&quot;]=&gt;
int(50001)
[&quot;roots&quot;]=&gt;
int(0)
}
</pre></div>
</div>
</div>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.gc-status-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><a href="features.gc.html" class="link">Garbage Collection</a></li>
</ul>
</p>
</div>
</div></div></div></body></html>