Moodle
  1. Moodle
  2. MDL-32214

when regarding quizzes with lots of attempts, php runs out of memory

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.5, 2.2.2
    • Fix Version/s: 2.1.6, 2.2.3
    • Component/s: Questions, Quiz
    • Labels:
    • Testing Instructions:
      Hide

      It is difficult to reproduce this, if you do not have the right (amount of) data.

      Paul Johnson was finding that it ran out of memory with about 100 attempts, with our default memory limit of 128MB.)

      1) Create a quiz,
      2) add a couple of questions to the quiz.
      3) attempt the quiz as student(s)
      4) as admin, under Navigation->yourquiz->Results->Grades, click on "Regarde all" or "Dryrun a full regrade" (let it show all attempts).
      In terms of memory leak consider the following:
      When memory limit = 128MB, it fails at about 100 attempts.

      (The other way to test this is to add print_object(memory_get_usage()); inside regrade_attempt(), and check that the memory usage stays about constant, rather than increasing linearly.)

      Show
      It is difficult to reproduce this, if you do not have the right (amount of) data. Paul Johnson was finding that it ran out of memory with about 100 attempts, with our default memory limit of 128MB.) 1) Create a quiz, 2) add a couple of questions to the quiz. 3) attempt the quiz as student(s) 4) as admin, under Navigation->yourquiz->Results->Grades, click on "Regarde all" or "Dryrun a full regrade" (let it show all attempts). In terms of memory leak consider the following: When memory limit = 128MB, it fails at about 100 attempts. (The other way to test this is to add print_object(memory_get_usage()); inside regrade_attempt(), and check that the memory usage stays about constant, rather than increasing linearly.)
    • Workaround:
      Hide

      At the end of the method regarde_attemp(), setting chuncky objects to NULL and using
      gc_collect_cycles() to force collection of any existing garbage cycles.

      Thanks to Tim.

      Show
      At the end of the method regarde_attemp(), setting chuncky objects to NULL and using gc_collect_cycles() to force collection of any existing garbage cycles. Thanks to Tim.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:

      Description

      when regarding quizzes with lots of attempts, php runs out of memory and does not finish "Regarde all" or "Dry run a full regarde" and cuases an error like "HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfil the request."

      PHP.log however, indicates a memory leak

        Gliffy Diagrams

          Activity

          Show
          Mahmoud Kassaei added a comment - Here is the diff: https://github.com/mkassaei/moodle/compare/MOODLE_22_STABLE...MDL-32214
          Hide
          Tim Hunt added a comment -

          Just two small problems Mahmoud:

          1. Even if it is difficult to test, you still have to write some testing instructions (Paul Johnson was finding that it ran out of memory with about 100 attempts, with our default memory limit of 128MB.)

          2. The comment comment needs to start by saying which part of the code is affected, so I would change it to something like

          MDL-32214 quiz regrading: with many attempts, PHP runs out of memory

          (Looking at https://github.com/mkassaei/moodle/commit/fa254d116ffebdad5084ca7bd5cf116649c03c06, you can also see that the first line of your commit comment was too long.)

          Show
          Tim Hunt added a comment - Just two small problems Mahmoud: 1. Even if it is difficult to test, you still have to write some testing instructions (Paul Johnson was finding that it ran out of memory with about 100 attempts, with our default memory limit of 128MB.) 2. The comment comment needs to start by saying which part of the code is affected, so I would change it to something like MDL-32214 quiz regrading: with many attempts, PHP runs out of memory (Looking at https://github.com/mkassaei/moodle/commit/fa254d116ffebdad5084ca7bd5cf116649c03c06 , you can also see that the first line of your commit comment was too long.)
          Hide
          Tim Hunt added a comment -

          Thanks Mahmoud. That looks good.

          To INTEGRATORS:

          Please cherry pick this to all stable branches 2.1 and later. Thanks.

          Show
          Tim Hunt added a comment - Thanks Mahmoud. That looks good. To INTEGRATORS: Please cherry pick this to all stable branches 2.1 and later. Thanks.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

          TIA and ciao

          Show
          Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
          Hide
          Dan Poltawski added a comment -

          Looks like gc_collect_cycles was introduced in php 5.3.0 (http://php.net/manual/en/function.gc-collect-cycles.php). Which is OK because we require 5.3.2 in 2.1

          Show
          Dan Poltawski added a comment - Looks like gc_collect_cycles was introduced in php 5.3.0 ( http://php.net/manual/en/function.gc-collect-cycles.php ). Which is OK because we require 5.3.2 in 2.1
          Hide
          Dan Poltawski added a comment -

          Thanks, that has been integrated now.

          Show
          Dan Poltawski added a comment - Thanks, that has been integrated now.
          Hide
          Tim Hunt added a comment -

          Ah, good thinking to check when that function was introduced. Thanks Dan.

          Show
          Tim Hunt added a comment - Ah, good thinking to check when that function was introduced. Thanks Dan.
          Hide
          Jason Fowler added a comment -

          As far as I can tell - with about 62 attempts in the quiz with HUGE essay answers, and then 63 attempts - the ram usage is staying the same. seems good to me

          Show
          Jason Fowler added a comment - As far as I can tell - with about 62 attempts in the quiz with HUGE essay answers, and then 63 attempts - the ram usage is staying the same. seems good to me
          Hide
          Aparup Banerjee added a comment -

          The code here has been spread to upstream moodle repositories and mirrors for anyone to use .

          Closing, have a good weekend!

          Show
          Aparup Banerjee added a comment - The code here has been spread to upstream moodle repositories and mirrors for anyone to use . Closing, have a good weekend!

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: