Skip to content

Commit

Permalink
adding memory check for FreeBSD also, TODO: refactor the free memory …
Browse files Browse the repository at this point in the history
…check into a function in an include file
  • Loading branch information
Tyrael committed Nov 2, 2011
1 parent ed27675 commit 5bf6eaf
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Zend/tests/bug55509.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@ if (PHP_OS == 'Linux') {
die('skip Not enough memory.');
}
}
elseif (PHP_OS == 'FreeBSD') {
$lines = explode("\n",`sysctl -a`);
$infos = array();
foreach ($lines as $line) {
if(!$line){
continue;
}
$tmp = explode(":", $line);
$index = strtolower($tmp[0]);
$value = trim($tmp[1], " ");
$infos[$index] = $value;
}
$freeMemory = ($infos['vm.stats.vm.v_inactive_count']*$infos['hw.pagesize'])
+($infos['vm.stats.vm.v_cache_count']*$infos['hw.pagesize'])
+($infos['vm.stats.vm.v_free_count']*$infos['hw.pagesize']);
if ($freeMemory < 2100*1024*1024) {
die('skip Not enough memory.');
}
}
?>
--INI--
memory_limit=2100M
Expand Down

0 comments on commit 5bf6eaf

Please sign in to comment.