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 .
and you are done .
You can also force collection of any existing garbage cycles by using
You read more about the Collecting Cycles here :