I have problem with the memory leak problem during the export of a large number of files from arrays of objects. Simplified code looks like this:
class Test_Class
{
private $a = null;
public function __construct($a = null)
{
$this->a = $a;
}
public function __destruct()
{
unset($this->a);
}
}
print 'Memory before: '.memory_get_usage(1).' <br>'; // 262 144
$a = [];
for ($i=0; $i<600000; $i++)
$a[] = new Test_Class($i);
print 'Memory after create: '.memory_get_usage(1).' <br>'; // 129 761 280
for($i=0; $i < count($a); $i++)
unset($a[$i]);
unset($a);
print 'Memory after: '.memory_get_usage(1).' <br>'; // 35 389 440
at the one of next iterations the memory still ends. Any idea how to free the memory occupied?
P.S. I try unset()/assignment null and gc_collect_cycles(), none of the methods has allowed me to release the memory occupied by the array of objects