From 0d7f4a31b22babb3505797cfa3dc7a185773e24f Mon Sep 17 00:00:00 2001 From: vargenau Date: Fri, 3 Oct 2014 14:24:21 +0000 Subject: [PATCH] function memory_get_usage exists git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@9173 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/stdlib.php | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/lib/stdlib.php b/lib/stdlib.php index 5ea94c23a..fbff2b198 100644 --- a/lib/stdlib.php +++ b/lib/stdlib.php @@ -2074,44 +2074,10 @@ function printSimpleTrace($bt) /** * Return the used process memory, in bytes. - * Enable the section which will work for you. They are very slow. - * Special quirks for Windows: Requires cygwin. */ function getMemoryUsage() { - //if (!(DEBUG & _DEBUG_VERBOSE)) return; - if (function_exists('memory_get_usage') and memory_get_usage()) { - return memory_get_usage(); - } elseif (function_exists('getrusage') and ($u = @getrusage()) and !empty($u['ru_maxrss'])) { - return $u['ru_maxrss']; - } elseif (substr(PHP_OS, 0, 3) == 'WIN') { // may require a newer cygwin - // what we want is the process memory only: apache or php (if CGI) - $pid = getmypid(); - $memstr = ''; - // win32_ps_stat_proc, win32_ps_stat_mem - if (function_exists('win32_ps_list_procs')) { - $info = win32_ps_stat_proc($pid); - $memstr = $info['mem']['working_set_size']; - } elseif (0) { - // This works only if it's a cygwin process (apache or php). - // Requires a newer cygwin - $memstr = exec("cat /proc/$pid/statm |cut -f1"); - - // if it's native windows use something like this: - // (requires pslist from sysinternals.com, grep, sed and perl) - //$memstr = exec("pslist $pid|grep -A1 Mem|sed 1d|perl -ane\"print \$"."F[5]\""); - } - return (integer)trim($memstr); - } else { - $pid = getmypid(); - //%MEM: Percentage of total memory in use by this process - //VSZ: Total virtual memory size, in 1K blocks. - //RSS: Real Set Size, the actual amount of physical memory allocated to this process. - //CPU time used by process since it started. - //echo "%",`ps -o%mem,vsz,rss,time -p $pid|sed 1d`,"\n"; - $memstr = exec("ps -orss -p $pid|sed 1d"); - return (integer)trim($memstr); - } + return memory_get_usage(); } /** -- 2.45.0