- var_dump: documentation ( source)
- simplexml_load_string: documentation ( source)
- gc_collect_cycles: documentation ( source)
- memory_get_usage: documentation ( source)
<?php
// Source: https://bugs.php.net/bug.php?id=62468
class SelfLinked
{
public $xml;
public $me;
public function __construct()
{
$this->xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?>
<a><b><c><d><e><f><g><h><i><j><k><l><m><n><o><p><q><r><s><t><u><v><w><x><y><z>waa?
</z></y></x></w></v></u></t></s></r></q></p></o></n></m></l></k></j></i></h></g></f></e></d></c></b></a>');
$this->me = $this;
}
}
$b = memory_get_usage();
for ($i = 0; $i < 1000; $i++)
{
new SelfLinked();
gc_collect_cycles();
}
var_dump(memory_get_usage() - $b);