Why isn't garbage collection being activated in my code? [migrated]
- by Netmoon
I have a foreach statement in my code, where each iteration calculates huge amounts of data and goes to the next iteration. I run this code, but when I read the log, I see there's a memory leak error.
PHP.net says when this happens, using gc_enabled() is a good way to handle this.
I've added these lines to last line of the foreach block:
echo "Check GC enabled : " . gc_enabled();
echo "Number of affected cycles : " . gc_collect_cycles();
And this is the output:
Check GC enabled : 1
Number of affected cycles : 0
Why do cycles exist, but the affected cycles is 0?