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

Memory leak in foreach ($analysables as $analysable) {

    XMLWordPrintable

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.9.6
    • None
    • Analytics
    • MOODLE_39_STABLE

    Description

      Add 300,000 users.
      Turn on analytics.
      Run php admin/cli/scheduled_task.php --execute=\\core\\task
      analytics_cleanup_task
      Notice memory error Fatal error.

      Basically, each iteration of user does return \core_analytics\user::instance($record, $context), which does new \core_analytics\user($user, $context);
      That allocates more memory.
      The memory never gets freed in the loop in foreach ($analysables as $analysable) {
      so there is a memory leak.

      I think the easy fix to this would be to call unset($analysable) in \core_analytics\manager::cleanup()

      Attachments

        Activity

          People

            Unassigned Unassigned
            jameskinsman James Kinsman
            David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated: