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

Extra garbage collection for analytics (backport of MDL-66234)

    XMLWordPrintable

    Details

      Description

      This is a backport of MDL-66234, copying its description below:

      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

              Assignee:
              dmonllao David Monllaó
              Reporter:
              dmonllao David Monllaó
              Peer reviewer:
              Simey Lameze
              Integrator:
              Eloy Lafuente (stronk7)
              Tester:
              CiBoT
              Participants:
              Component watchers:
              Elizabeth Dalton, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón, Matteo Scaramuccia, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Nov/19

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 2 minutes
                  1h 2m