The rationale behind the ability to turn the mechanism on and off, and to initiate cycle collection yourself, is that some parts of your application could be highly time-sensitive. In those cases, you might not want the garbage collection mechanism to kick in. Of course, by turning off the garbage collection for certain parts of your application, you do risk creating memory leaks because some possible roots might not fit into the limited root buffer. Therefore, it is probably wise to call gc_collect_cycles() just before you call gc_disable() to free up the memory that could be lost through possible roots that are already recorded in the root buffer. This then leaves an empty buffer so that there is more space for storing possible roots while the cycle collecting mechanism is turned off.
Je trouvais ton idée séduisante, mais après lecture de la doc, un peu moins.
[^] # Re: Forum Programmation.php— fuite mémoirePHP
Posté par maboiteaspam . En réponse au message fuite mémoire PHP. Évalué à 1.
http://php.net/manual/en/features.gc.collecting-cycles.php
Je trouvais ton idée séduisante, mais après lecture de la doc, un peu moins.