i have foreach statement in my code. each step calculate huge data,and goes to next step. i run this code and going to do my works,when i’m going back and read log, see memory leak error. so read php.net and find that gc_collect_cycle is good for this case.
add this lines to last line of foreach block:
echo "Check GC enabled : " . gc_enabled();
echo "Number of affected cycles : " . gc_collect_cycles();
output is this :
Check GC enabled : 1
Number of affected cycles : 0
why cycle is exist but affected cycles is 0?
In this case cycle is not means cycle-statement (e.g. foreach).
Cycles means cycle-refernces in code. See http://php.net/manual/en/features.gc.collecting-cycles.php