- memory_get_peak_usage: documentation ( source)
- gc_collect_cycles: documentation ( source)
- number_format: documentation ( source)
<?php
function create() {
$a = new stdClass();
$b = new stdClass();
$b->a = $a;
// $b->cb = function() use ($a) {
// };
$a->b = $b;
return $a;
}
echo number_format(memory_get_peak_usage() / 1000000, 2, '.', ' '), " MB\n";
for ($i = 0; $i < 1000; ++$i) {
create();
// $a->b = new ArrayObject();
}
gc_collect_cycles();
echo number_format(memory_get_peak_usage() / 1000000, 2, '.', ' '), " MB\n";