I know that once a script ends, all objects are destroyed and memory is returned. Does this also happen to function-scoped objects once the function ends that aren't accessible anyway?
For instance, I'm worried about memory leaks in my PHPUnit tests, wherein I create a new object for almost every test. Will this eventually overflow my heap if I run enough tests?
public function testMyFunction()
{
// Arrange
$myObject = new MyClass();
// Act
$return = $myObject->myFunction();
// Assert
$this->assertEquals(true, $return);
}
Should I be manually unset
ting them for long-running scripts in an "Absterge" section?
public function testMyFunction()
{
// Arrange
$myObject = new MyClass();
// Act
$return = $myObject->myFunction();
// Assert
$this->assertEquals(true, $return);
// Absterge
unset($myObject);
}