假设一个对象具有大量数据的属性,在析构函数中取消设置这些属性,是否比让PHP自由释放该对象分配的内存更加高效?
class A {
protected $foo;
protected $bar;
protected $baz;
public function __construct()
{
$this->foo = big_amount_of_data();
$this->bar = reference_to_a_big_object();
$this->foo = data_from_big_file();
}
public function doProcess()
{
// do something
}
public function __destruct()
{
// Should I do this?
unset(
$this->foo,
$this->bar,
$this->baz
);
}
}