Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-66234

Extra garbage collection for analytics

    XMLWordPrintable

Details

    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

          Activity

            People

              dmonllao David Monllaó
              dmonllao David Monllaó
              Carlos Escobedo Carlos Escobedo
              Andrew Lyons Andrew Lyons
              CiBoT CiBoT
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                18/Nov/19

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 week, 1 hour, 15 minutes
                  1w 1h 15m