您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php 内存使用信息代码

2024/11/23 4:17:13发布31次查看
通过侦测脚本的内存使用情况,有利于代码的优化。php 提供了一个垃圾收集器和一个非常复杂的内存管理器。脚本执行时所使用的内存量,有升有跌。为了得到当前的内存使用情况,我们可以使用 memory_get_usage() 函数。如果需要获得任意时间点的最高内存使用量,则可以使用 memory_limit() 函数。view sourceprint?01 echo initial:
 代码如下 复制代码
.memory_get_usage(). bytes ; 
02 /* prints 
03 initial: 361400 bytes 
04 */
05   
06 // let's use up some memory 
07 for ($i = 0; $i
08  $array []= md5($i); 
09 } 
10   
11 // let's remove half of the array 
12 for ($i = 0; $i
13  unset($array[$i]); 
14 } 
15   
16 echo final: .memory_get_usage(). bytes ; 
17 /* prints 
18 final: 885912 bytes 
19 */
20   
21 echo peak: .memory_get_peak_usage(). bytes ; 
22 /* prints 
23 peak: 13687072 bytes
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product