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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Deferred
    • Icon: Minor Minor
    • None
    • 3.9.6
    • Analytics
    • MOODLE_39_STABLE

      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()

            Unassigned Unassigned
            jameskinsman James Kinsman
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.