title: How do I flush memory use in CodeIgniter
body: <p>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: </p>
  
  <pre><code>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
  </code></pre>
  
  <p>For detail please see the attached file.</p>
  
  <p>Here data are fetched from <strong>Progress server using JSON</strong>. 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.</p>
  
  <p>I tried to use <strong>ob_end_flush(), ob_flush()</strong>,.. but could not get desire result.
  I am too is unaware about how to use in CI.</p>
  
  <p>I hope I am able to clear my problem.
  Thank you in advance for the support.</p>
  
  <p>I am using HMVC.</p>
  
  <p>CODE</p>
  
  <pre><code>// controller
      public function get_event_images(){    
          // pagination
          $data['current_page'] = @$_GET['page']?@$_GET['page']:1;
  
          $data['event_id'] = $this-&gt;uri-&gt;segment(3);   
          $data['event_name'] = urldecode($this-&gt;uri-&gt;segment(4));  
          $url = JSON_URL."jsread.p?call=treeimg&amp;user=&amp;lang=en&amp;tree=".$data['series_id']."&amp;sort=last&amp;max=".MAX_RECORD."&amp;startpage=".$data['current_page']."&amp;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'  =&gt;$data['event_id'],
              'event_name'=&gt; $data['event_name']
          );
          $this-&gt;session-&gt;set_userdata($newdata);
  
          $this-&gt;load-&gt;view('ktmevent/template_page', $data);         
      }
  
  
  
  // view
      if(!empty($images)):
          foreach($images as $data):
              echo  "&lt;li&gt;";   
                  echo  "&lt;div class=\"image\"&gt;";  
                  echo "&lt;a href=\"".site_url('events/image_detail/'.$series_id."/".$data['Photono'])."\"&gt;";
                  echo "&lt;img src=\"http://www.mysite.com".$data['Thumburl']."\" /&gt;";
                  echo "&lt;/a&gt;";
                  echo "&lt;/div&gt;";
                  echo "&lt;div&gt;";
                  echo anchor('events/image_detail/'.$series_id.'/'.$data['Photono'], 'Detail');
                  echo "&lt;/div&gt;";
              echo "&lt;/li&gt;";
          endforeach;
      endif;
  </code></pre>