Thread: Memory Leak
View Single Post
Old 07-13-2006, 08:07 AM   #1
kwa1975
Green Mole
 
Join Date: Jul 2006
Posts: 1
Exclamation Memory Leak

In search_function.php about lines 277-284, one can read:
Code:
else {
    $num_exclude[$n] = $num_res_temp;
          while (list($spider_id,$weight) = mysql_fetch_array($result)) {
                 $s_exclude[$n][$spider_id] = 1;
          }
    mysql_free_result($result);
    }
}
It appears the MySQL results are not freed up in every case. I believe the intended code was:
Code:
else {
    $num_exclude[$n] = $num_res_temp;
          while (list($spider_id,$weight) = mysql_fetch_array($result)) {
                 $s_exclude[$n][$spider_id] = 1;
          }
    }
    mysql_free_result($result);
}
In fact, I wonder why the MySQL result is not freed a bit later, about lines 284-290:
Code:
      elseif (!isset($exclude[$n])) {
              $num_res[$n] = 0;
              $s_weight[$n][0] = 0;
     }
     mysql_free_result($result);
     $timer->stop('spider fills');
}
That memory leak might make some searches fail on some huge spider and sites databases.
kwa1975 is offline   Reply With Quote