Last Updated: February 25, 2016
· samuelm

PHP 5.3 : Garbage Collector

Since version 5.3 PHP introduced a garbage collector to handle memory leaks issue for big scripts ( a well know feature for C developper )

It's very easy to use and will save a lot of memory for you batch scripts .

Just call


and you are done .

You can also force collection of any existing garbage cycles by using


You read more about the Collecting Cycles here :

2 Responses
Add your response

Do you have any examples of when one may find a need for this?

over 1 year ago ·

I recomand this article about circular references that explain why you need a garbage collector to be enable.

In real life it's needed for background batch operation that could run for hours for example .

over 1 year ago ·