当前位置:Gxlcms > PHP教程 > 获取内存使用信息的PHP代码

获取内存使用信息的PHP代码

时间:2021-07-01 10:21:17 帮助过:11人阅读

使用这个php代码,你就可以知道你服务器上使用RAM(内存)的情况。
  1. echo "Initial: ".memory_get_usage()." bytes \n";
  2. /* prints
  3. Initial: 361400 bytes
  4. */
  5. // let's use up some memory
  6. for ($i = 0; $i < 100000; $i++) {
  7. $array []= md5($i);
  8. }
  9. // let's remove half of the array
  10. for ($i = 0; $i < 100000; $i++) {
  11. unset($array[$i]);
  12. }
  13. echo "Final: ".memory_get_usage()." bytes \n";
  14. /* prints
  15. Final: 885912 bytes
  16. */
  17. echo "Peak: ".memory_get_peak_usage()." bytes \n";
  18. /* prints
  19. Peak: 13687072 bytes
  20. */

PHP

人气教程排行