- array_map: documentation ( source)
- var_dump: documentation ( source)
- memory_get_usage: documentation ( source)
- array_fill: documentation ( source)
<?php
$a1 = array_fill(0, 100000, true);
foreach($a1 as $k => $v){ unset($a1[$k]); }
var_dump(memory_get_usage());
$a2 = array_map(function($v){ return $v; }, $a1); // capacity is trimmed down. how many resizes are performed?
unset($a1);
var_dump(memory_get_usage());
$a2[] = true;
var_dump(memory_get_usage());