Use zone_memory_cap as RAM limit if set https://github.com/webmin/webmin/issues/149

This commit is contained in:
Jamie Cameron
2014-05-16 10:50:48 -07:00
parent 68a860dd2a
commit 88d7282c36

View File

@@ -219,12 +219,15 @@ if (!&has_command("kstat")) {
return ( );
}
local %stat;
foreach my $s ("physmem", "freemem") {
foreach my $s ("physmem", "freemem", "zone_memory_cap") {
local $out = &backquote_command("kstat -p -m unix -s $s");
if ($out =~ /\s+(\d+)/) {
$stat{$s} = $1;
}
}
if ($stat{'zone_memory_cap'} > $stat{'physmem'}) {
delete($stat{'zone_memory_cap'});
}
local ($swaptotal, $swapfree);
&open_execute_command(SWAP, "swap -l", 1);
while(<SWAP>) {
@@ -237,8 +240,10 @@ close(SWAP);
local $pagesize = &backquote_command("pagesize 2>/dev/null");
$pagesize = int($pagesize)/1024;
$pagesize ||= 8; # Fallback
return ($stat{'physmem'}*$pagesize, $stat{'freemem'}*$pagesize,
$swaptotal/2, $swapfree/2);
return (($stat{'zone_memory_cap'} || $stat{'physmem'})*$pagesize,
$stat{'freemem'}*$pagesize,
$swaptotal/2,
$swapfree/2);
}