php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3311 Memory Hog
Submitted: 2000-01-25 10:11 UTC Modified: 2000-07-24 12:48 UTC
From: dan at nek0 dot net Assigned:
Status: Closed Package: Performance problem
PHP Version: 3.0.12 OS: Solaris
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dan at nek0 dot net
New email:
PHP Version: OS:

 

 [2000-01-25 10:11 UTC] dan at nek0 dot net
After running a script which queries a MySQL database about 6000+ times in rapid succession, the apache daemon hogs upto 30-40Mb ram and doesn't release it, even though I use mysql_free_results() straight after queries have been performed.
Is this a PHP bug? or a Solaris problem...?

If you have an ideas I'd like to know for future reference etc.
<?php

>>> This following SQL query holds about 6000+ results

     21         if (!$results_link_ids = mysql_db_query($db_name, "SELECT link_id FROM links ORDER by name", $db_connection)) {
     22                 error($PHP_SELF, "Failed link_id lookup");
     23         }
     24         while ($row = mysql_fetch_array($results_link_ids)) {
     25                 if (!$results_count = mysql_db_query($db_name, "SELECT COUNT(*) AS count FROM catmap WHERE link_id = $row[link_id]", $db_connection)) {
     26                         error($PHP_SELF, "Failed count lookup");
     27                 }
     28                 if (!mysql_result($results_count, 0, "count")) {
     29                         mysql_free_result($results_count);
     30                         if (!$results_link_details = mysql_db_query($db_name, "SELECT name, description, url FROM links WHERE link_id = $row[link_id]", $db_connection)) {
     31                                 error($PHP_SELF, "Failed link details lookup");
     32                         }
     33                         $link_details = mysql_fetch_array($results_link_details);
     34                         mysql_free_result($results_link_details);
     35                         print "<li><b><a href=\"$link_details[url]\" target=\"_new\">$link_details[name]</a></b><br>";
     36                         print "<font size=\"-2\">";
     37                         print "$link_details[url]<br>";
     38                         print nl2br($link_details[description])."<br>";
     39                         print "<br></font>";
     40                         ++$unlink_count;
     41                 }
     42         }
     43         if (!$unlink_count) {
     44                 print "<center><b>There are no unlinked links</b></center>";
     45         }
     46         else {
     47                 mysql_free_result($results_link_ids);
     48         }
     49 ?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-24 12:48 UTC] hholzgra at cvs dot php dot net
php3 is not to good at memory management, 
you should really consider using php4 instead
(at least it worked for me in a similar case)
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 16:01:36 2025 UTC