When trying to import resources to a course that is in a large category, PHP runs out of memory. Increasing the memory_limit is the workaround, but Moodle code could be improved also:
/course/import/activities/mod.php is reading category course information with
$cat_courses = get_courses($course->category);
This loads all of the course data for all of the category courses, but then the script only uses the course id and the course full name, as fas as I understand. So it takes a lot more memory than necessary. Default PHP limit of 128M can hold around 1200 courses, we ran out of mem when a category had 1278 courses.
Could /course/import/activities/mod.php only read the course information that it really needs?
To reproduce: have a category with a lot of courses (hundreds or thousands) with descrriptions and moddata in them. Reduce the memory_limit of PHP to something like 8M or 16M. Go to a course in a large category and click Import from the admin block. A semi-blank page appears. PHP ran out of memory.