<?php
var_dump(ini_get('memory_limit'));
function memstat($file, $line) {
echo sprintf(
'mem @ %s %d: %.2f MB (%.2f MB; peak: %.2f MB)' . PHP_EOL,
$file,
$line,
memory_get_usage() /2**20,
memory_get_usage(true) /2**20,
memory_get_peak_usage() /2**20
);
}
memstat(__FILE__, __LINE__);
$str = str_pad('', 9999999, ' ');
memstat(__FILE__, __LINE__);
print 'end '.strlen($str);
- Output for 7.3.0 - 7.3.21, 7.4.0 - 7.4.9, 8.0.30, 8.2.10
- string(3) "64M"
mem @ /in/BHqWd 16: 0.37 MB (2.00 MB; peak: 0.41 MB)
mem @ /in/BHqWd 18: 9.91 MB (11.54 MB; peak: 9.91 MB)
end 9999999
- Output for 7.2.0 - 7.2.33
- string(3) "64M"
mem @ /in/BHqWd 16: 0.37 MB (2.00 MB; peak: 0.40 MB)
mem @ /in/BHqWd 18: 9.91 MB (11.54 MB; peak: 9.91 MB)
end 9999999
preferences:
54.45 ms | 407 KiB | 5 Q