Unset()
Posted: Mon Jan 19, 2009 1:07 pm
Hello,
I've been lately thinking about the unset() function. Let's take a quick sample code from my cache class:
At this point, would PHP automatically unset $new_array and $array after this stop using function? Of course they are cleared at the end of the script execution (garbage collector), but during the run - will they be unsetted()? I guess no. So should I do that myself? I think no since the data is minimalistic. The $array is perhaps from 0 to 15 bytes long and the $new_array a bit more (a figure like 1 kB sounds normal). Since allowed memory usage is usually at least 8 MB, that means I am far from the border.
But where do you set the "limit"? What if I'm working on an $array that is 500 kB in size? What about an array of 1 MB in size? Shouldn't I unset those?
Maybe I should check the size of the array and then determine whether unset(), am I being completely overcomplicated (sounds funny
) here?
I've been lately thinking about the unset() function. Let's take a quick sample code from my cache class:
Code: Select all
public function cached_sql_fetch_row($result)
{
$array = $result[$this -> sqlrowpointer++];
$new_array = array();
foreach ($array as $row_name => $row_value)
$new_array[] = $row_value;
return $new_array;
}But where do you set the "limit"? What if I'm working on an $array that is 500 kB in size? What about an array of 1 MB in size? Shouldn't I unset those?
Maybe I should check the size of the array and then determine whether unset(), am I being completely overcomplicated (sounds funny