Bug #3311: Memory Hog
| From: | dan at nek0 dot net | Date: | Tue, 25 Jan 2000 15:11:41 +0000 |
| Subject: | Bug #3311: Memory Hog | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-14910@lists.php.net to get a copy of this message | ||
From: dan@nek0.net
Operating system: Solaris
PHP version: 3.0.12
PHP Bug Type: Performance problem
Bug description: Memory Hog
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 ?>