In the previous section we have simply mentioned that recycling may have subtle performance effects on the root, but this is when comparing PHP 5.2 with PHP 5.3. Although in PHP 5.2, the record may be slower than the root at all, and other modifications to PHP run-time in PHP 5.3 reduce this performance penalty.
There are two main areas that have an impact on performance. The first is the memory footprint savings, and the other is the increase in execution time (run-time delay) when the garbage collection mechanism performs memory cleanup. We will study these two areas.
Savings in memory footprint
First, the entire reason for implementing the garbage collection mechanism is to save memory consumption by cleaning up the variables referenced by the loop once the prerequisites are met. In PHP execution, garbage collection is performed once the root buffer is full or when the Gc_collect_cycles () function is called. In, the following script shows the memory footprint of PHP 5.2 and PHP 5.3 respectively, excluding the basic memory that PHP itself occupies when the script starts.
Example #1 Memory Usage Example
<?php class Foo {public $var = ' 3.1415962654 '; } $baseMemory = Memory_get_usage (); for ($i = 0; $i <= 100000; $i + +) { $a = new Foo; $a->self = $a; if ($i% = = 0) { echo sprintf ('%8d: ', $i), Memory_get_usage ()-$baseMemory, "\ n"; } } ?>
The above is the PHP characteristics of garbage collection mechanism 3--performance considerations of the content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!