Re: php cli question

From: Date: Wed, 15 Sep 2010 02:01:19 +0000
Subject: Re: php cli question
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-308078@lists.php.net to get a copy of this message
Per Jessen wrote:
J Ravi Menon wrote:
2) What about garbage collection? In a standard apache-mod-php setup, we rely on the end of a request-cycle to free up resources - close file descriptiors, free up memory etc.. I am assuming in the aforesaid standalone daemon case, we would have to do this manually?
Yes.
So 'unset($some_big_array)' or 'unset($some_big_object)' etc.. is the right way to go for non-resource based items? i.e. it needs to be explicitly done?
It's not quite like C - if you reassign something, the previous contents are automagically freed. I use unset() if I know it could be a while (hours) before it'll likely be reassigned, but it won't be used in the meantime.
Has anybody done a comparison of setting to null rather than unset'ing; does unset invoke the garbage collector instantly? i.e. is unset the best approach to clearing objects from memory quickly? Best, Nathan

« previous php.general (#308078) next »