title: PHP Fatal error: Allowed memory size of 268435456 bytes exhausted
body: <p>I keep seeing a memory exhausted error</p>
  
  <blockquote>
    <p>PHP Fatal error: Allowed memory size of 268 435 456 bytes exhausted</p>
  </blockquote>
  
  <p>in my log file.</p>
  
  <p>This error comes randomly even when the server is very lightly loaded &amp; not reproducible on localhost. I have a VPS 4 server from hostgator with with loads of MB. The php config allows upto 256 Mb. </p>
  
  <p>The code is below</p>
  
  <pre><code>function func_select_array($qry)
  {
      $i=0;
      $data=array();
      $qry_result=mysql_query($qry);
  
      if($qry_result)
      {
          while ($row=mysql_fetch_assoc($qry_result))
          {
              $data[$i] = $row;
              $i++;
          }
          return $data;
      }
      else 
      {
        return 2;
      }
  }
  
  
      function func_check_rule_out_bid($auc_id,$bid_amount,$return_freq,$recheck)
      {
          $bid_qry="select * from tbl_bid where ubaid='".$auc_id."' and ubf='1' order by uba desc limit 0,10";
          $bid_array=func_select_array($bid_qry);
      }
  </code></pre>
  
  <p>The table tbl_bid has 2800 records. 
  I get memory exhausted error in the while loop inside func_select_array function. 
  I cannot imagine this query needs 256M+. It does not appear to be a php problem, but something in mysql. Please help...</p>