0
In php we have the method unset
to erase variables from memory, I have a doubt about that.
After a method is executed, are its local variables automatically deleted from memory? Or is it good practice to use the unset
to erase them and release a little?
Follow an example:
private function getAllFiles()
{
$files = (new FinderFiles)->getFiles();
$progress = ProgressHelper::start($this->output, 'files', count($files));
$repository = ClassesRepository::instance();
foreach ($files as $file) {
$repository->pushClass(new AnalyzedClass($file->getRealPath()));
$progress->advance();
}
$progress->finish();
unset($files, $progress, $repository);
}
With the line unset($files, $progress, $repository);
program would consume less memory or the exclusion of these variables is already made?
Although the question Linkei is not exactly the same, I am considering that answers your question. If you do not answer, let me know here.
– bfavaretto
I read the question you passed, a phrase from the first answer gave an indirect answer to my question.
– Leonardo