<?php
set_time_limit(0);
echo 'memory_limit:'. $memory = ini_get('memory_limit').'<br />';
$string = 'abcde'; // 运行字符串, 可修改这儿.
$memory =($memory+0)*1024*1024;
$runtime = memory_get_usage();
$runcount = $memory / (strlen($string)+1); // 为什么+1? 因为需要留点内存给其它变量或者计算式.
$i = 0;
while($i < $runcount){
$i ++;
$data .= $string;
}
echo 'all run count: '.$i.'<br />';
echo '\$data string size:'. sprintf('%01.2f',strlen($data) / 1024 / 1024) .'MB <br />';
echo 'run memory: '. sprintf('%01.2f',(memory_get_usage() - $runtime) / 1024 / 1024) .'MB';
exit();
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn