-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
4.1.10, 4.2.7, 4.3
-
None
-
MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE
we're hitting a memory limit with the train models task in Moodle's analytics
PHP Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 134217736 bytes)
due to this line:
https://github.com/moodle/moodle/blob/master/analytics/classes/analysis.php#L533
The way I read that code is:
wait until we have over 1000 records, then run an insert - this part makes sense:
https://github.com/moodle/moodle/blob/master/analytics/classes/analysis.php#L528
But then it takes the first 1000 records from that array and passes it to the insert_records call and anything over that it saves in the $newcalculations var to deal with on the next loop - but I'm not clear why it's actually doing this as array_splice just seems to result in more memory usage than less.
I think we just need to pull out the array_splice and just send the full array to insert_records rather than keeping back the extra items in the array over 1000
I'll try to get a PR for this, although testing analytics is always a bit problematic so it might sit here for a while....