Skip to content
Advertisement

Disable Garbage Collection

How do I disable garbage collection for a long running php cli script? I am handling unsetting of variables in the script.

Advertisement

Answer

Unsetting variables does not free memory! It just removes the reference from the variable to the corresponding value. Once any value have a ref-count of 0 the GC collects the value and frees its allocated memory. If it would be possible to completely disable the GC you would break your interpreter (in best case): You will have many many unreferenced data in your memory, that will never get cleaned. Thats called “memory leak”.

Is there garbage collection in PHP?

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement