PHP garbage collection mechanism

Source: Internet
Author: User

PHP garbage collection mechanism is php5 after this thing, I would like to introduce to you about the PHP garbage collection mechanism Some understanding, I hope you have some help.

The garbage collection mechanism used before PHP 5.3 is a simple "reference count", that is, each memory object is assigned a counter, when the memory object is referenced by a variable, counter 1; When the variable reference is removed, the counter-1; when the counter = 0 o'clock indicates that the memory object is not being used, the memory object is destroyed. Garbage collection is complete.

The problem with reference counting is that when two or more objects reference each other to form a ring, the counter of the memory object is not reduced to 0; At this time, this set of memory objects is useless, but cannot be recycled, resulting in memory leaks;

php5.3 started with a new garbage collection mechanism, based on reference counting, a complex algorithm was implemented to detect the existence of reference rings in memory objects to avoid memory leaks.

PHP garbage collection mechanism

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.