- gc_collect_cycles: documentation ( source)
- memory_get_usage: documentation ( source)
<?php
class Foo
{
public $x;
public function __construct($self) {
$this->x = $self;
}
}
Class Bar {
static function create(){
$b = new Bar();
$b->f = new Foo($b->get());
}
function get(){
$self = $this;
return function() use ($self) {return $self;};
}
}
echo memory_get_usage(), "\n";
for ($i = 0; $i < 1000; ++$i) {
Bar::create();
}
echo gc_collect_cycles() . "\n";
echo memory_get_usage(), "\n";