Home  >  Article  >  Backend Development  >  PHP Features Garbage Collection Mechanism 2 - Recycling Cycle

PHP Features Garbage Collection Mechanism 2 - Recycling Cycle

黄舟
黄舟Original
2017-02-04 09:48:201456browse

Traditionally, the reference counting memory mechanism used in PHP cannot handle circular reference memory leaks. However, 5.3.0 PHP uses the synchronization algorithm in the article » Concurrent Cycle Collection in Reference Counted Systems to deal with this memory leak problem.
A complete description of the algorithm is somewhat beyond the scope of this section, and only the basics will be introduced. First, we need to establish some basic rules. If a reference count is increased, it will continue to be used and of course no longer in the garbage. If the reference count is reduced to zero, the variable container will be cleared (free). That is, a garbage cycle occurs only when the reference count decreases to a non-zero value. Secondly, during a garbage cycle, find out which parts are garbage by checking whether the reference count is reduced by 1 and checking which variable containers have zero references.

PHP Features Garbage Collection Mechanism 2 - Recycling Cycle

The above is the content of the garbage collection mechanism 2 of PHP characteristics - the recycling cycle. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn