We briefly mentioned in the previous section that recycling may have a slight performance impact, but this is only when comparing PHP 5.2 with PHP 5.3. Although in PHP 5.2, logging may be slower than not logging at all, other changes to the PHP run-time in PHP 5.3 reduce this performance penalty.
There are two main areas here that have an impact on performance. The first is the saving of memory space, and the other is the increase in execution time (run-time delay) when the garbage collection mechanism performs memory cleaning. We will look at both areas.
Saving memory space
First of all, the whole reason for implementing a garbage collection mechanism is to save memory footprint by cleaning up circularly referenced variables once the prerequisites are met. In PHP execution, garbage collection is performed once the root buffer is full or the gc_collect_cycles() function is called. In the figure below, the memory usage of the following scripts in PHP 5.2 and PHP 5.3 environments is shown, excluding the basic memory occupied by PHP itself when the script is started.
Example #1 Memory usage example
self = $a; if ( $i % 500 === 0 ) { echo sprintf( '%8d: ', $i ), memory_get_usage() - $baseMemory, "\n"; } } ?>
The above is the content of PHP Features Garbage Collection Mechanism 3 - Performance Considerations. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!