-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
Hello,
I'm using Mac OS 10.15.6 (Catalina) and getRam function return incorrect result.
Here explained :
use Linfo\Linfo;
require 'vendor/autoload.php';
$linfo = (new Linfo())->getParser();
print_r($linfo->getRam());Result :
Array
(
[type] => Physical
[total] => 17179869184
[free] => 17432133632
[swapTotal] => 0
[swapFree] => 0
[swapInfo] => Array
(
)
)
As you can see, free mem is greater than available. sysctl hw.usermem return `hw.usermem: -216473600'. So I try to take only the absolute value (216473600) but it still wrong.
My current free RAM is about 3Gb.
A little trick allow me to get the free RAM in Dawin.php (I don't like to "unitPows trick but... it works)
$freeMemory = trim($this->exec->exec('top', '-l 1 | grep PhysMem | sed "s/.*, //" | sed "s/ .*//"'));
$unitPows = [
'K' => 1,
'M' => 2,
'G' => 3,
];
$unit = substr($freeMemory, -1);
$freeMemory = (int) $freeMemory;
$freeMemory = $freeMemory * pow(1024, $unitPows[$unit]);Gives me 2008023040 (2Gb because my RAM available is about 2Gb ^^)
Hope you will find a fix with sysctlvelse I can make a merge request to put modification.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels