Reputation: 454
I am facing problem of site break down. Since this is the site related to photos. It’s using almost 95% of memory of server. When it reaches to 100% the site is down. I checked from the profiler, and get following details:
Loading Time: Base Classes 0.0404
Controller Execution Time ( Events / Get Series Images ) 10.7655
Total Execution Time 10.8061
MEMORY USAGE : 3,948,864 bytes
For detail please see the attached file.
Here data are fetched from Progress server using JSON. I am surprise what made it so. But in my mind one thing hunt, why not to free the memory when work is done? I went to different forum of CI but could not get the answer.
I tried to use ob_end_flush(), ob_flush(),.. but could not get desire result. I am too is unaware about how to use in CI.
I hope I am able to clear my problem. Thank you in advance for the support.
I am using HMVC.
CODE
// controller
public function get_event_images(){
// pagination
$data['current_page'] = @$_GET['page']?@$_GET['page']:1;
$data['event_id'] = $this->uri->segment(3);
$data['event_name'] = urldecode($this->uri->segment(4));
$url = JSON_URL."jsread.p?call=treeimg&user=&lang=en&tree=".$data['series_id']."&sort=last&max=".MAX_RECORD."&startpage=".$data['current_page']."&pagesize=".PAGE_SIZE;
$json_formated_data = readJSONURL($url);
//extract array of images only
$data['images'] = getData($json_formated_data);
$image_stat = getImageStat($json_formated_data);
$data['total_images']= $image_stat[6];
$data['total_rows'] = $image_stat[5];
$data['main_content'] = 'eventimages';
$data['title'] = "Event Images";
// store series details in session
$newdata = array(
'event_id' =>$data['event_id'],
'event_name'=> $data['event_name']
);
$this->session->set_userdata($newdata);
$this->load->view('ktmevent/template_page', $data);
}
// view
if(!empty($images)):
foreach($images as $data):
echo "<li>";
echo "<div class=\"image\">";
echo "<a href=\"".site_url('events/image_detail/'.$series_id."/".$data['Photono'])."\">";
echo "<img src=\"http://www.mysite.com".$data['Thumburl']."\" />";
echo "</a>";
echo "</div>";
echo "<div>";
echo anchor('events/image_detail/'.$series_id.'/'.$data['Photono'], 'Detail');
echo "</div>";
echo "</li>";
endforeach;
endif;
Upvotes: 1
Views: 3795
Reputation: 1522
You could start with finding out what the memory usage is during each action. Just output the memory using the PHP function memory_get_usage():
http://php.net/manual/en/function.memory-get-usage.php
Then you should be able to determine the actions that would cause your application to fill up the memory buffers.
Upvotes: 2