-
Bug
-
Resolution: Fixed
-
Minor
-
3.1.3
-
MOODLE_31_STABLE
-
MOODLE_31_STABLE, MOODLE_32_STABLE
-
MDL-57515-master -
In resource_get_coursemodule_info, it calls $fs->get_area_files when it actually only needs to retrieve a single file. There is a TODO comment stating that this is 'not very efficient'.
We have a use case where a resource may contain more than 10,000 files (if anyone's interested, this is to do with zoomable tiled images where you have many tiles making up an image). In some cases, this causes the system to run out of memory when rebuilding the course cache. (It turns out that running out of memory while rebuilding course cache is a really bad state to be in for the system...) It is anyway a lot more RAM-hungry than it should be.
Using my local machine (latest versions), a resource with 15,000 files means rebuilding course cache uses 81.3MB RAM peak with this code. After a simple fix, the RAM peak drops to 26.8MB (which is about the same as it would be if you didn't have a resource with 15,000 files). It also runs several times faster.