I have a script that sometimes break because I get an error like:
PHP Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes) in ...
The memory limit is NOT too low and was put at 128M. (This should be more than enough.)
The problem is that as the script goes, it takes more and more memory. Basically, it's a for
loop. I've checked every variable but there is no place where the script fills 'something' (for example, an array) that would grow and explain why the script takes more memory.
I confirmed the memory problem using: memory_get_usage()
. I've printed out the memory footprint after each iteration and the number is always higher.
Using Xdebug does show not any sign that can help me at this point.
Is there any way I could drilldown and know what is taking more memory everytime I loop ? What would you suggest to debug that situation ?