- memory_get_peak_usage: documentation ( source)
<?php
// 标准array
// $array = array(1024 * 1024); // array();
// for ($i = 0; $i < 1024 * 1024; ++$i)
// $array[$i] = 0;
// echo 'Standard array: '.memory_get_peak_usage();
// spl
$SplFixedArray = new SplFixedArray(1024 * 1024); // array();
for ($i = 0; $i < 1024 * 1024; ++$i)
$SplFixedArray[$i] = 0;
echo 'SplFixedArray: '.memory_get_peak_usage();