Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.8
-
MOODLE_38_STABLE
-
MOODLE_38_STABLE
-
MDL-66234_master -
Description
Further testing for MDLSITE-5663 revealed that a chunk of data was not removed by PHP's garbage collector. After several days investigating the issue I ended up identifying a late initialisation of the CLI renderer as the root cause for the memory leak. $PAGE is not initialised until the grades API (required by one of the indicators used in the model) is called, moodle_page::_wherethemewasinitialised is then set to debug_backtrace() which contains the indicator instance so the instance is not garbage collected until the end of the script, when moodle_page is destroyed, blocking that chunk of data allocated in PHP's memory until the end of the script. PHP instances are not removed from memory when there are references to them, even when calling unset($instance) and this is what was happening in this case.
The provided patch includes a couple of performance improvements to free memory back to the OS as soon as possible,
Attachments
Issue Links
- Discovered while testing
-
MDLSITE-5663 Enable Moodle analytics features in learn.moodle.org
-
- Resolved
-
- will be (partly) resolved by
-
MDL-66394 Extra garbage collection for analytics (backport of MDL-66234)
-
- Closed
-
- will help resolve
-
MDL-65839 Review the memory usage of the evaluation process and the initial training process
-
- Closed
-