PHP features-garbage collection mechanism 3-performance considerations

Source: Internet
Author: User
As we mentioned in the previous section, recycling may have a slight performance impact, but it is only available when PHP5.2 and PHP5.3 are compared. Although in PHP5.2, the root of the record may be slower than the root of the non-record at all, other modifications to PHPrun-time in PHP5.3 reduce this performance loss. As we mentioned in the previous section, recycling may have a slight performance impact, but it is only available when comparing PHP 5.2 with PHP 5.3. Although in PHP 5.2, the root of the record may be slower than the root of the non-record, other modifications to PHP run-time in PHP 5.3 reduce this performance loss.
There are two main fields that affect the performance. The first is the space savings in memory usage, and the other is the increase in execution time (run-time delay) when the garbage collection mechanism cleans up memory ). We will study these two fields.
Memory space savings
First, the whole reason for implementing the garbage collection mechanism is to save memory usage by clearing the variables referenced by the loop once the prerequisites are met. In PHP execution, once the root buffer is full or the gc_collect_cycles () function is called, garbage collection is executed. In, it shows the memory usage of the following scripts in PHP 5.2 and PHP 5.3 respectively, excluding the basic memory occupied by PHP when the script is started.
Example #1 Example of memory usage

 self = $a;          if ( $i % 500 === 0 )          {              echo sprintf( '%8d: ', $i ), memory_get_usage() - $baseMemory, "\n";          }      }  ?>

The above is the garbage collection mechanism of PHP features 3-performance considerations. For more information, see PHP Chinese website (www.php1.cn )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.