日期:2014-05-17  浏览次数:20533 次

PHP memory_limit 问题解决

???? memory_limit虽然可以调节内存大小,但是如果一个php脚本里有比较大的DB结果集或者数组、对象等,或者有众多的结果集,如果这些占用资源的对象得不到及时释放,可能在脚本后面一截执行过程中出现 Allowed memory size of? xxx bytes exhausted at?xxx:xxx (tried to allocate xxx bytes)的问题,所以这种情况下还是要及时的进行内存释放unset($xx),特别是一些CLI的PHP程序。

?

PHP vesion >=V5.2

memory_get_usage():http://php.chinaunix.net/manual/en/function.memory-get-usage.php

memory_get_peak_usage():http://php.chinaunix.net/manual/en/function.memory-get-peak-usage.php

?