最新下载
热门教程
- 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; } } } |
相关文章
- 忘川风华录唐伯虎怎么培养 唐伯虎养成攻略 09-18
- 无限暖暖音乐季她的回旋我的向往任务怎么过 她的回旋我的向往任务攻略 09-18
- 新三国志曹操传南华幻境天境9-2怎么过 南华幻境天境9-2过关攻略 09-18
- 火环维吉尔技能是什么 维吉尔技能介绍 09-18
- 发条总动员金币怎么获取 金币获取攻略 09-18
- 不朽箴言雅典娜怎么培养 雅典娜养成攻略 09-18