php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52252 PHp seems to run out of memory
Submitted: 2010-07-05 16:13 UTC Modified: 2013-02-18 00:34 UTC
From: wimroffel at planet dot nl Assigned:
Status: No Feedback Package: Output Control
PHP Version: 5.3.2 OS: Windows xp
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: wimroffel at planet dot nl
New email:
PHP Version: OS:

 

 [2010-07-05 16:13 UTC] wimroffel at planet dot nl
Description:
------------
For my site I generate a large number of PHP pages from a PHP script. Experience learns that PHP is not totally realiable and that some of the pages will contain errors. The errors may be small but unlike html PHP is unforgiving and it immediately results in a single php error line.

So I made a script to check all my php files. I use the output buffering functions to direct their output to a file. I then measure the size of this output. If this is extremely small it must be a PHP error line. 

After reading some 30 to 120 files PHP just stops. For a given directory it is always the same. Total filesize (all files together) before the stop varied between 500 and 3500 kb.

Test script:
---------------
function checkfile($myfile)
{ if (!file_exists($myfile)) return;
  echo $myfile."<br>";
  ob_start();
  include($myfile);
  $data = ob_get_contents();
  ob_end_clean();
  if(strlen($data) < 500) echo "<h2>".$myfile." is too small!</h2>";
}

  $dp = opendir("./"));
  while( $dirfile = readdir($dp))
  { if(($dirfile == ".") || ($dirfile == "..")) // all files are php
      continue;
   checkfile($dirfile);
  }
  closedir($dp);

Expected result:
----------------
I would expect that the script would process all the files in the directory

Actual result:
--------------
Instead it just processes a certain number and then stops. This is no timeout: it happens within a second.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-05 18:12 UTC] rasmus@php.net
-Status: Open +Status: Feedback
 [2010-07-05 18:12 UTC] rasmus@php.net
Are you actually getting an out of memory error?  

What I think is happening is that one of the files you
include has a syntax error in it which will immediately
abort your script.

Remove the ob_start() and run your script and watch for
errors.
 [2010-07-05 18:23 UTC] rasmus@php.net
A better way to do what you are trying to do is to run each
file through a separate php processor so a fatal error won't
terminate your checking script.  Like this:

foreach(glob("./*.php") as $f) {
  $out = null;
  exec("php -l $f", $out, $ret);
  if($ret) {
    echo "Problem in $f\n{$out[1]}";
  }
}
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Nov 06 07:01:30 2024 UTC