aboutsummaryrefslogtreecommitdiffstats
path: root/lib/os_mon/src
diff options
context:
space:
mode:
authorFredrik Gustafsson <[email protected]>2013-11-04 12:30:01 +0100
committerFredrik Gustafsson <[email protected]>2013-11-04 12:30:01 +0100
commitc911744728926ee44a8dafd1ad44168dcc97201e (patch)
tree5f6e6a4a4e42059d462e0de08b1d3576f306be1a /lib/os_mon/src
parent82803a5f91adb7825de911edc6965ab8f1f57a17 (diff)
parent6cc7d88683f581fd6a1619aea8c3c5309f4f4013 (diff)
downloadotp-c911744728926ee44a8dafd1ad44168dcc97201e.tar.gz
otp-c911744728926ee44a8dafd1ad44168dcc97201e.tar.bz2
otp-c911744728926ee44a8dafd1ad44168dcc97201e.zip
Merge branch 'cmeiklejohn/csm-fix-memsup-problems/OTP-11454' into maint
* cmeiklejohn/csm-fix-memsup-problems/OTP-11454: Fix incorrect reporting of memory on OS X via memsup.
Diffstat (limited to 'lib/os_mon/src')
-rw-r--r--lib/os_mon/src/memsup.erl19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/os_mon/src/memsup.erl b/lib/os_mon/src/memsup.erl
index a1b8591c8c..b178732fae 100644
--- a/lib/os_mon/src/memsup.erl
+++ b/lib/os_mon/src/memsup.erl
@@ -721,20 +721,19 @@ reply(Pending, MemUsage, SysMemUsage) ->
%% get_memory_usage(OS) -> {Alloc, Total}
%% Darwin:
-%% Uses vm_stat command. This appears to lie about the page size in
-%% Mac OS X 10.2.2 - the pages given are based on 4000 bytes, but
-%% the vm_stat command tells us that it is 4096...
+%% Uses vm_stat command.
get_memory_usage({unix,darwin}) ->
Str1 = os:cmd("/usr/bin/vm_stat"),
-
- {[Free], Str2} = fread_value("Pages free:~d.", Str1),
- {[Active], Str3} = fread_value("Pages active:~d.", Str2),
- {[Inactive], Str4} = fread_value("Pages inactive:~d.", Str3),
- {[_], Str5} = fread_value("Pages speculative:~d.", Str4),
+ PageSize = 4096,
+
+ {[Free], Str2} = fread_value("Pages free:~d.", Str1),
+ {[Active], Str3} = fread_value("Pages active:~d.", Str2),
+ {[Inactive], Str4} = fread_value("Pages inactive:~d.", Str3),
+ {[Speculative], Str5} = fread_value("Pages speculative:~d.", Str4),
{[Wired], _} = fread_value("Pages wired down:~d.", Str5),
- NMemUsed = (Wired + Active + Inactive) * 4000,
- NMemTotal = NMemUsed + Free * 4000,
+ NMemUsed = (Wired + Active + Inactive) * PageSize,
+ NMemTotal = NMemUsed + (Free + Speculative) * PageSize,
{NMemUsed,NMemTotal};
%% FreeBSD: Look in /usr/include/sys/vmmeter.h for the format of struct