Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect available memory on OpenBSD. #2

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/vm_memory_monitor.erl
Expand Up @@ -239,10 +239,13 @@ get_total_memory({unix,darwin}) ->
PageSize * (Inactive + Active + Free + Wired);

get_total_memory({unix,freebsd}) ->
PageSize = freebsd_sysctl("vm.stats.vm.v_page_size"),
PageCount = freebsd_sysctl("vm.stats.vm.v_page_count"),
PageSize = sysctl("vm.stats.vm.v_page_size"),
PageCount = sysctl("vm.stats.vm.v_page_count"),
PageCount * PageSize;

get_total_memory({unix,openbsd}) ->
sysctl("hw.usermem");

get_total_memory({win32,_OSname}) ->
%% Due to the Erlang print format bug, on Windows boxes the memory
%% size is broken. For example Windows 7 64 bit with 4Gigs of RAM
Expand Down Expand Up @@ -342,7 +345,7 @@ parse_line_aix(Line) ->
false -> list_to_integer(Value)
end}.

freebsd_sysctl(Def) ->
sysctl(Def) ->
list_to_integer(cmd("/sbin/sysctl -n " ++ Def) -- "\n").

%% file:read_file does not work on files in /proc as it seems to get
Expand Down