title: Codeigniter - Allowed memory size exhausted while uploading
body: <p>I noticed there are similar questions but I have tried the proposed solutions and could not come up with a solution.</p>
  
  <p>Here is my development environment:</p>
  
  <ul>
  <li>PHP 5.3.10-1ubuntu3.4 with Suhosin-Patch (cli) </li>
  <li>Server version: Apache/2.2.22 (Ubuntu)</li>
  <li>Codeigniter_2.1.2</li>
  </ul>
  
  <p>What I'm trying to do is the basic example of the image upload. Here is the controller:</p>
  
  <pre><code>&lt;?php
  
  class Entry extends CI_Controller {
  
      function __construct() {
          parent::__construct();
          ini_set('memory_limit', "256M");
      }
  
      function index() {
          $this-&gt;load-&gt;view('upload_form');
      }
  
      function upload() {
  
          $config['upload_path'] = './uploads/';
          $config['allowed_types'] = 'gif|png|jpg';
          $config['max_size'] = 2048;
          $config['max_width'] = 1024;
          $config['max_height'] = 768;
  
          $this-&gt;load-&gt;library('upload', $config);
  
          if (! $this-&gt;upload()-&gt;do_upload('file')) {
              $error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
  
              $this-&gt;load-&gt;view('upload_form', $error);
          }
      }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>And my view file is simply like this:</p>
  
  <pre><code>&lt;?php
      echo form_open_multipart('entry/upload');
      echo form_upload('file');
      echo form_submit('submit', 'Upload Fille');
  ?&gt;
  </code></pre>
  
  <p>In the controller, you can see that I've tried setting memory limit to 256MB, I also tried the -1 option. When I set the memory_limit to -1 the computer ran crazy, it froze ((:</p>
  
  <p>Here is the error that I'm getting when I try to upload sth.</p>
  
  <pre><code>PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 523800 bytes) in /var/www/giydir/system/core/Common.php on line 358, referer: http://localhost/giydir/entry
  </code></pre>
  
  <p>The line that the error shows is interesting to me</p>
  
  <pre><code>$_log =&amp; load_class('Log');
  </code></pre>