私は得る:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 18635837 bytes) in /Users/[...]/cake/libs/cache/file.php on line 135
そして、何がRAMを大量に消費するのか理解できません。
広範な配列とデータを含む大きな変数があります。私のコントローラーは次のように終了します:
// RENDER
$this->set(compact('var1', 'var2'));
debug(memory_get_usage()); // prints out: 33997240
33MB は 134MB には遠く及ばない
ビューの最初の行として配置debug(memory_get_usage());
すると、致命的なエラーが発生します。これは、問題がビューのループにないことを意味します。コントローラーにもないようですが、コントローラーとビューの間にあります。
問題の内容を調査し、問題を解決するにはどうすればよいですか?
EDIT< 関数全体のコード:
function assignment_results($aid=null, $uid=null){
if($aid==null){
$this->Session->setFlash(__('Sorry but my butt got booted. 1907125790'));
$this->redirect($this->Misc->redirectHome());
}
$assignment = $this->EduAssignment->getById($aid);
// Get User IDS
if($uid==null){
$cus = $this->EduCourseUser->getStudentsForCourseId($assignment['EduAssignment']['edu_course_id']);
foreach ($cus as $cu){
$uids[]=$cu['EduCourseUser']['user_id'];
}
}else{
$uids[]=$uid;
}
// GET WORDING
$course = $this->EduCourse->getById($assignment['EduCourse']['id']);
$wt = $this->WritingTranslation->getById($assignment['EduAssignment']['writing_translation_id']);
$writing['Writing'] = $wt['Writing'];
if($writing['Writing']['type']== 'song' || $writing['Writing']['type']== 'video')
$this->paginate['limit'] = 2000;
$wording = $this->paginate('Word', array('Word.writing_translation_id'=>$wt['WritingTranslation']['id']));
$word_ids = array();
foreach($wording as $w){
$word_ids[]=$w['Word']['id'];
}
// CLICKS
$this->Click->unbindModel(array('belongsTo' => array('Word' )));
$clicks = $this->Click->getForAssignmentUserIds($assignment['EduAssignment']['id'], $uids);
// Assign clicks to words
foreach ($wording as &$wg){
$num = 0;
foreach ($clicks as $cl){
if($wg['Word']['id']==$cl['Click']['word_id']){
$num++;
}
}
$wg['Word']['click_number'] = $num;
}
// List of words by how many times clicked:
$wording_sorted = $wording;
// echo(memory_get_usage());
uasort($wording_sorted, array('TeachController', '_cmp'));
// debug(memory_get_usage());
// RENDER
$this->set(compact('writing', 'wording','wording_sorted', 'assignment', 'course'));
// debug(memory_get_usage());
}
function _cmp($a, $b){
return $a['Word']['click_number']<$b['Word']['click_number'];
}