Home >php教程 >php手册 >PHP检测获取内存信息

PHP检测获取内存信息

WBOY
WBOYOriginal
2016-06-13 09:37:411101browse

   PHP也可以检测获取到Windows的内存信息,而且代码还挺简单,无意发现的,觉得以后能用上,在此与大家分享。

  本代码将得到总内存、初始使用等内存信息:

  01

  02echo "初始: ".memory_get_usage()." 字节 \n";

  03for ($i = 0; $i

  04 $array []= md5($i);

  05}

  06for ($i = 0; $i

  07 unset($array[$i]);

  08}

  09echo "最终: ".memory_get_usage()." 字节 \n";

  10echo "内存总量: ".memory_get_peak_usage()." 字节 \n";

  11?>

  运行结果示例:

  初始: 66104 字节 最终: 590600 字节 内存总量: 12591704 字节

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