In fetch_all_helper, it does get_records_select, which loads a whole lot of data into an array. Then it immediately turns those records into objects, and puts them in another array. 2 arrays == twice as much memory use as is ready needed. We should change this to get_recordset_select.
Patch attached. Please can we get this into 1.9 quickly. Becuase of this problem we cannot delete gradebook columns on a course with 40,000 students.
2.0-compatible patch to follow.