From: Ferenc Kovacs Date: Sun, 23 Oct 2011 00:07:01 +0000 (+0000) Subject: check the available memory on linux and skip if it is not enough X-Git-Tag: php-5.5.0alpha1~993 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c67c8cb96508001d455b1d0036de360f19ec566d;p=php check the available memory on linux and skip if it is not enough --- diff --git a/Zend/tests/bug55509.phpt b/Zend/tests/bug55509.phpt index d9957cd5fb..3f8657facd 100644 --- a/Zend/tests/bug55509.phpt +++ b/Zend/tests/bug55509.phpt @@ -5,6 +5,21 @@ Bug #55509 (segfault on x86_64 using more than 2G memory) if (PHP_INT_SIZE == 4) { die('skip Not for 32-bits OS'); } +// check the available memory +if (PHP_OS == 'Linux') { + $lines = file('/proc/meminfo'); + $infos = array(); + foreach ($lines as $line) { + $tmp = explode(":", $line); + $index = strtolower($tmp[0]); + $value = (int)ltrim($tmp[1], " ")*1024; + $infos[$index] = $value; + } + $freeMemory = $infos['memfree']+$infos['buffers']+$infos['cached']; + if ($freeMemory < 2100*1024*1024) { + die('skip Not enough memory.'); + } +} ?> --INI-- memory_limit=2100M