Skip to content

Commit bb793ee

Browse files
committed
Detect available memory on OpenBSD.
While there, rename freebsd_sysctl() to sysctl(), since sysctl is available on number of different platforms.
1 parent fe47ee0 commit bb793ee

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/vm_memory_monitor.erl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,13 @@ get_total_memory({unix,darwin}) ->
239239
PageSize * (Inactive + Active + Free + Wired);
240240

241241
get_total_memory({unix,freebsd}) ->
242-
PageSize = freebsd_sysctl("vm.stats.vm.v_page_size"),
243-
PageCount = freebsd_sysctl("vm.stats.vm.v_page_count"),
242+
PageSize = sysctl("vm.stats.vm.v_page_size"),
243+
PageCount = sysctl("vm.stats.vm.v_page_count"),
244244
PageCount * PageSize;
245245

246+
get_total_memory({unix,openbsd}) ->
247+
sysctl("hw.usermem");
248+
246249
get_total_memory({win32,_OSname}) ->
247250
%% Due to the Erlang print format bug, on Windows boxes the memory
248251
%% size is broken. For example Windows 7 64 bit with 4Gigs of RAM
@@ -342,7 +345,7 @@ parse_line_aix(Line) ->
342345
false -> list_to_integer(Value)
343346
end}.
344347

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

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

0 commit comments

Comments
 (0)