|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-08-08 09:26 UTC] juhl at eisenstein dot dk
After upgrading to latest CVS I'm getting errors due to the memory limit that I've not encountered before. Even small scripts (that worked perfectly with PHP 4.0.0) are now getting killed when theyt hit my mem-limit of 25MB. I think something is leaking memory since I do not get this error for about the first hour after restarting Apache, but after aproximately 1 hour the scripts start to crash with this message: Fatal error: Allowed memory size of 25165824 bytes exhausted (tried to allocate 256 bytes) in Unknown on line 0 Running "top" or "ps" shows no processes using huge amounts of mem, and each httpd process is consuming about 3% of my 128MB RAM each time they run. Restarting apache makes the problem go away again for about half an hour to an hour. I'm running Slackware Linux 7.0, Apache 1.3.12, PHP 4.02-dev (php4-200008080345). PHP was configured like this: ./configure --with-mysql=/usr/local/mysql --with-apxs=/usr/local/apache/bin/apxs --with-config-file-path=/etc/httpd --enable-calendar --enable-trans-sid --enable-versioning --enable-track-vars --with-gd --with-jpeg-dir --with-tiff-dir --with-png-dir --with-ttf --with-zlib-dir --enable-memory-limit=yes --with-openssl --disable-debug Best regards, Jesper Juhl PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 10 20:00:02 2026 UTC |
The following script exhibits the described behaviour (the amount of time until the problem shows itself can vary depending (I guess) on server load). The function makeStrSafe() is defined in juhlFunctions.php and looks like this: function makeStrSafe($str) { $str = trim($str); $str = eregi_replace("[^-a-zA-Z?????? 0-9.,_]", "", $str); return $str; } The session.php file is rather large, and so is the db.php file that defines the db class (included in session.php), so I'll only post them on request. The err_return() function currently does nothing, it's just defined like this: function err_return($a, $b) { exit(); } <?php $INCLUDE_DIR = "/include/"; require($DOCUMENT_ROOT.$INCLUDE_DIR."juhlFunctions.php"); $username = makeStrSafe($username); $password = makeStrSafe($password); require($DOCUMENT_ROOT.$INCLUDE_DIR."session.php"); $k = makeStrSafe($k); if ($k != $klub) { $klub = $k; } session_register("klub"); if (empty($klub)) { header("Location: http://".$SERVER_NAME."klubVaelger.php"); exit(); } $dbase = new db; if (!$dbase->connect()) { err_return($dbase->errno, $dbase->errmsg); } $filename = "medlem_forside.php"; if (!($fp = fopen($filename, "r"))) { err_return("r", "Kunne ikke åbne filen $filename"); } if (!($contents = fread($fp, filesize($filename)))) { err_return("r", "Kunne ikke læse filen $filename"); } fclose($fp); $dbase->query = "LOCK TABLES klub READ, person READ"; if (!$dbase->execQuery()) { err_return($dbase->errno, $dbase->errmsg); } $dbase->query = "SELECT navn FROM klub WHERE post_id='$klub'"; if (!$dbase->execQuery()) { err_return($dbase->errno, $dbase->errmsg); } if (mysql_num_rows($dbase->result) == 0) { echo "Klubben findes ikke<br>"; exit(); } $row = mysql_fetch_array($dbase->result); $contents = eregi_replace("<klubNavn>", "$row[navn]", $contents); $dbase->query = "SELECT fornavn, efternavn FROM person WHERE post_id='$row[leder_id]'"; if (!$dbase->execQuery()) { err_return($dbase->errno, $dbase->errmsg); } $row = mysql_fetch_array($dbase->result); $contents = eregi_replace("<klubLederNavn>", $row[fornavn]." ".$row[efternavn], $contents); $dbase->query = "UNLOCK TABLES"; if (!$dbase->execQuery()) { err_return($dbase->errno, $dbase->errmsg); } echo $contents; ?>