note 87091 deleted from function.memory-get-usage by danbrown
| From: | danbrown@php.net | Date: | Wed, 19 Nov 2008 14:39:52 +0000 |
| Subject: | note 87091 deleted from function.memory-get-usage by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146714@lists.php.net to get a copy of this message | ||
Note Submitter: miteigi nemoto (mitiegi at yandex dot ru)
----
Decision a memory_get_usage problem for windows system
Tested OS: Windows XP
Server: Apache
PHP must be loaded as CGI to get correctly memory usage by Process ID ( getmypid() ) and with
cmd-tools like tasklist.exe
PHP as CGI have your own PID instead constant Apache PID and you get a true memory size independed
form Apache memory usage.
Configure in httpd.conf of Apache:
1. Comment the line like this:
LoadModule php4_module "/usr/local/php/sapi/php4apache.dll"
or
LoadModule php5_module "/usr/local/php5/php5apache.dll"
2. Add this and edit your path to php:
<Directory "z:/usr/local/php">
Options ExecCGI
</Directory>
ScriptAlias "/__php_dir__/" "z:/usr/local/php/"
Action application/x-httpd-php "/__php_dir__/php.exe"
3. Restart Apache
Use this PHP-code:
<?php
/**
* A memory_get_usage() for Windows System, wich compiled without --enable-memory-limit
* PHP must be loaded as CGI
* Greetings form miteigi nemoto
* @return string
*/
function memory_get_usage_by_tasklist()
{
$output = array();
exec( 'tasklist ', $output );
foreach ($output as $value)
{
$ex=explode(" ",$value);
$count_ex=count($ex);
if (eregi(" ".getmypid()." Console",$value))
{
$memory_size=$ex[$count_ex-2]." Kb";
return $memory_size;
}
}
}
echo memory_get_usage_by_tasklist();
?>