Here a controller to raise the error
<?php
//----file name: /controllers/testdb.php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Testdb extends CI_Controller {
public function index() {
echo "<h1>DB Memmore Exhaustion TEST (128Mb)</h1>";
echo "<ol>";
echo "<li><a href='testdb/create_db'>Create a table with 4k records</a></li>";
echo "<li><a href='testdb/run_test'>Run test</a></li>";
echo "</ol>";
}
public function Run_test() {
$query=$this->db->get('ci_mem_test');
foreach($query->result() as $row){//<---- This line will exhaust 128Mb
}
}
public function Create_db() {
//---load dbforge
set_time_limit(3600);
$this->load->dbforge();
$this->dbforge->drop_table('ci_mem_test');
$this->dbforge->add_field('id');
$this->dbforge->create_table('ci_mem_test');
$object=new stdClass();
$object->id=0;
for($i=1;$i<=400000;$i++){
$this->db->insert('ci_mem_test',$object);
}
//$this->output->enable_profiler(TRUE);
}
}
/* End of file testdb.php */
/* Location: ./application/controllers/testdb.php */
