Remove create_function() from dml.php to save memory

Bug #1132370 reported by Aaron Wells
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Aaron Wells
1.5
Fix Released
Medium
Aaron Wells
1.6
Fix Released
Medium
Aaron Wells

Bug Description

While trying to optimize memory usage in the mahara.org cron jobs (which keep crashing due to running out of memory), I noticed from the error stacks that it kept crashing on the call to create_function() in db_quote_table_placeholders() in dml.php

The reason for this, is because functions created by create_function() are never garbage collected. They persist for the lifetime of the script's execution. Which means that if you put it inside a loop that gets called thousands of times, it keeps using up more and more memory with new copies of the function, until the script crashes from running out of RAM.

There are about a dozen other usages of create_function() in Mahara's codebase, but this is the only one that's likely to be used in a large loop.

Revision history for this message
Aaron Wells (u-aaronw) wrote :
Changed in mahara:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Aaron Wells (u-aaronw)
milestone: none → 1.8.0rc1
Revision history for this message
Aaron Wells (u-aaronw) wrote :

Fix was released as part of 1.7.0. It could make sense to backport it to 1.5 and 1.6, though.

Changed in mahara:
milestone: 1.8.0rc1 → none
status: In Progress → Fix Released
Aaron Wells (u-aaronw)
Changed in mahara:
milestone: none → 1.7.2
Robert Lyon (robertl-9)
Changed in mahara:
milestone: 1.7.2 → none
milestone: none → 1.6.6
Changed in mahara:
milestone: 1.6.6 → none
Revision history for this message
Robert Lyon (robertl-9) wrote :

added patchset for 1.5_STABLE
https://reviews.mahara.org/#/c/2309/

added patchset for 1.6_STABLE
https://reviews.mahara.org/#/c/2310/

Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/2310
Committed: http://gitorious.org/mahara/mahara/commit/2ba43bfddda3959b42f85bf6bf66c5b309399471
Submitter: Robert Lyon (<email address hidden>)
Branch: 1.6_STABLE

commit 2ba43bfddda3959b42f85bf6bf66c5b309399471
Author: Aaron Wells <email address hidden>
Date: Sun Feb 24 21:17:07 2013 +1300

Bug #1132370 Remove create_function() from dml.php to save memory

Functions created by create_function() don't ever get deallocated,
which contributes to scripts running out of memory.

Change-Id: Ifd78bf05bab67a9b1593a7d9722dd2433e7ad7ca
Signed-off-by: Aaron Wells <email address hidden>

Revision history for this message
Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/2309
Committed: http://gitorious.org/mahara/mahara/commit/2e0c66c0e13f9267ecabee2f15273ca48c872e0d
Submitter: Robert Lyon (<email address hidden>)
Branch: 1.5_STABLE

commit 2e0c66c0e13f9267ecabee2f15273ca48c872e0d
Author: Aaron Wells <email address hidden>
Date: Sun Feb 24 21:17:07 2013 +1300

Bug #1132370 Remove create_function() from dml.php to save memory

Functions created by create_function() don't ever get deallocated,
which contributes to scripts running out of memory.

Change-Id: Ifd78bf05bab67a9b1593a7d9722dd2433e7ad7ca
Signed-off-by: Aaron Wells <email address hidden>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.