set osm2pgsql cache memory to a default based on memory in the machine

This commit is contained in:
Brian Quinion
2012-04-26 01:35:06 +01:00
parent 7b430bc731
commit 9b01ddd641
2 changed files with 25 additions and 9 deletions

View File

@@ -57,6 +57,20 @@
return sizeof($aMatches[0]);
}
function getTotalMemoryMB()
{
$sCPU = file_get_contents('/proc/meminfo');
preg_match('#MemTotal: +([0-9]+) kB#', $sCPU, $aMatches);
return (int)($aMatches[1]/1024);
}
function getCacheMemoryMB()
{
$sCPU = file_get_contents('/proc/meminfo');
preg_match('#Cached: +([0-9]+) kB#', $sCPU, $aMatches);
return (int)($aMatches[1]/1024);
}
function bySearchRank($a, $b)
{
if ($a['iSearchRank'] == $b['iSearchRank']) return 0;