最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PHP获得内存使用状态memory_get_usage()函数
时间:2022-06-24 21:37:39 编辑:袖梨 来源:一聚教程网
格式化memory_get_usage()输出
代码如下 | 复制代码 |
function convert($size){ |
输出:256 kb
PHP memory_get_usage() 函数还可以有个参数,$real_usage,其值为布尔值。默认为 FALSE,表示得到的内存使用量不包括该函数(PHP 内存管理器)占用的内存;当设置为 TRUE 时,得到的内存为不包括该函数(PHP 内存管理器)占用的内存。
例
代码如下 | 复制代码 |
if (!function_exists('memory_get_usage')) { { $pid = getmypid(); if (IS_WIN) { exec('tasklist /FI "PID eq ' . $pid . '" /FO LIST', $output); return preg_replace('/[^0-9]/', '', $output[5]) * 1024; } else { exec("ps -eo%mem,rss,pid | grep $pid", $output); $output = explode(" ", $output[0]); return $output[1] * 1024; } } } |
相关文章
- 《1号会员店》关闭自动续费方法 01-29
- 《排球少年:新的征程》社团每日福利领取方法 01-29
- 《椿之歌》新手风属性队伍推荐 01-29
- 《最终幻想14:水晶世界》小小阿托莫斯宠物获得方法 01-29
- 《燕云十六声》醉拳客打法攻略 01-29
- 《异人之下》全货币获取方法汇总 01-29