I wrote my own version of memory_get_usag e() if that function is not
available:
[PHP]
if (!function_exis ts('memory_get_ usage')) {
/**
* Determine the amount of memory you are allowed to have
*
* @access public
* @return long
* @link
http://us2.php.net/manual/en/function.memory-get-usage.php#64156
* @see link regarding usage of memory_get_usag e() homegrown function
* @see DBActionPerform er
*/
function memory_get_usag e() {
// NEW 1/15/2007: EMERGENCY PATCH TO REINTRODUCE DBActionPerform er
if (!class_exists( 'DBActionPerfor mer')) {
global $basePath;
if (!class_exists( 'MethodGenerato rForActionPerfo rmer'))
require_once("$ basePath/include/classes.inc.php ");
require_once("$ basePath/include/db_action.inc.p hp");
}
$dbAP =& new DBActionPerform er(); // NO DB ACTION REQUIRED HERE JUST
THE CLASS OBJECT INSTANCE FOR getKommandOSArr ay() METHOD
list($memKomman d, $memRedirect) =
@array_values($ dbAP->getKommandOSAr ray('allowed-memory'));
$outputArray = array();
exec("$memKomma nd $memRedirect", $outputArray);
if ($_ENV['windir'] || $_SERVER['windir']) {
return preg_replace( '/[\D]/', '', $outputArray[5]) * 1024;
} else {
$outputArray = @explode(' ', $outputArray[0]);
return $outputArray[1] * 1024;
}
}
}
[/PHP]
This function works in *nix and Win XP Pro and Win 2003 Server with no
problems.
However, the dev environment is using Win XP Home with PHP 5.2.0 and
the function is not only not available, my homegrown version breaks as
well because "tasklist" is a DOS program only available to Win XP Pro
and Win 2003 Server, definitely not to XP Home.
Because of this I need another variation of my function but don't have
any idea where to begin to look. "pslist" is also not an option
because the business requirement for the app is that it must be a
dual-functioning (Windows and *nix) PHP PORTABLE web application, so
you have to pack it up and go every time, so having executables along
like "pslist" is not always a viable option.
Suggestions?
Thanx
Phil
available:
[PHP]
if (!function_exis ts('memory_get_ usage')) {
/**
* Determine the amount of memory you are allowed to have
*
* @access public
* @return long
* @link
http://us2.php.net/manual/en/function.memory-get-usage.php#64156
* @see link regarding usage of memory_get_usag e() homegrown function
* @see DBActionPerform er
*/
function memory_get_usag e() {
// NEW 1/15/2007: EMERGENCY PATCH TO REINTRODUCE DBActionPerform er
if (!class_exists( 'DBActionPerfor mer')) {
global $basePath;
if (!class_exists( 'MethodGenerato rForActionPerfo rmer'))
require_once("$ basePath/include/classes.inc.php ");
require_once("$ basePath/include/db_action.inc.p hp");
}
$dbAP =& new DBActionPerform er(); // NO DB ACTION REQUIRED HERE JUST
THE CLASS OBJECT INSTANCE FOR getKommandOSArr ay() METHOD
list($memKomman d, $memRedirect) =
@array_values($ dbAP->getKommandOSAr ray('allowed-memory'));
$outputArray = array();
exec("$memKomma nd $memRedirect", $outputArray);
if ($_ENV['windir'] || $_SERVER['windir']) {
return preg_replace( '/[\D]/', '', $outputArray[5]) * 1024;
} else {
$outputArray = @explode(' ', $outputArray[0]);
return $outputArray[1] * 1024;
}
}
}
[/PHP]
This function works in *nix and Win XP Pro and Win 2003 Server with no
problems.
However, the dev environment is using Win XP Home with PHP 5.2.0 and
the function is not only not available, my homegrown version breaks as
well because "tasklist" is a DOS program only available to Win XP Pro
and Win 2003 Server, definitely not to XP Home.
Because of this I need another variation of my function but don't have
any idea where to begin to look. "pslist" is also not an option
because the business requirement for the app is that it must be a
dual-functioning (Windows and *nix) PHP PORTABLE web application, so
you have to pack it up and go every time, so having executables along
like "pslist" is not always a viable option.
Suggestions?
Thanx
Phil
Comment