]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/lib.php
set osm2pgsql cache memory to a default based on memory in the machine
[nominatim.git] / lib / lib.php
index 1564a83cceffa45dc4a1f65ef29cce3d87cb0608..889cb2cff3fe92f80624d7bccbc2f981f4405d59 100644 (file)
                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;