so I am using php 5.2 and needing some garbage collection since I am dealing with very limited resources and large data sets.
from my tests I have seen that unset does nothing until the end of the script(even if I run out of memory), which seems a little bit contrary to the documentation, although I assume that I am also reading the 5.3 docs not the 5.2 docs and the 5.3 docs seem relatively undocumented.
An barebones sample of my class is as follows:
class foo{
private $_var;
public function __construct(){
$this->_var = array();
for($i = 0; $i < 10000000000; $i++){
$this->_var[rand(1, 100000)] = 'I am string '.$i.' in the array';
}
}
public function myGC(){
$this->_var = null;
}
}
in my function 'myGC()' should I do a foreach over the array and set each element I encounter to NULL (as I remember doing in C++) or would setting $this->_var = NULL free not only the pointer to the array but also all elements associated with the pointer?