Neither mod/quiz/backuplib.php nor question/backuplib seem to be doing anything too evil.
$quiz_attempts = get_records("quiz_attempts","quiz",$quiz,"id");
$question_states = get_records("question_states","attempt",$attempt,"id");
$rqp_state = get_record("question_rqp_states","stateid",$state);
so it loads one record about each attempt into memory. Then for each attempt, it loads all the records about that attempt.
So, while these would be prime candidates for get_recordSET, I don't think that is what is causing memory to run out.