function apdqc_install_total_memory in Asynchronous Prefetch Database Query Cache 7
Identify the total amount of system memory available.
Return value
int
1 call to apdqc_install_total_memory()
- apdqc_requirements in ./
apdqc.install - Implements hook_requirements().
File
- ./
apdqc.install, line 1824 - Handles APDQC installation and status checks.
Code
function apdqc_install_total_memory() {
// Cache the value statically so this is only processed once.
static $total_memory;
// First time through, identify how much system memory there is.
if (is_null($total_memory)) {
// Windows uses the command "wmic".
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
exec('wmic memorychip get capacity', $total_memory);
unset($total_memory['0']);
$total_memory = array_sum($total_memory);
}
elseif (strtoupper(substr(PHP_OS, 0, 6)) == 'DARWIN') {
exec('system_profiler SPHardwareDataType', $total_memory);
$total_memory = $total_memory[12];
$total_memory = explode(':', $total_memory);
$total_memory = apdqc_install_human2byte(trim($total_memory[1]));
}
else {
$data = explode("\n", file_get_contents("/proc/meminfo"));
$total_memory = apdqc_install_human2byte(substr($data[0], 9));
}
}
return $total_memory;
}