Skip to content

Log MiB instead of MB and report total of bytes #1249

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

Merged
merged 1 commit into from
Jun 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/vm_memory_monitor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

-define(SERVER, ?MODULE).
-define(DEFAULT_MEMORY_CHECK_INTERVAL, 1000).
-define(ONE_MB, 1048576).
-define(ONE_MiB, 1048576).

%% For an unknown OS, we assume that we have 1GB of memory. It'll be
%% wrong. Scale by vm_memory_high_watermark in configuration to get a
Expand Down Expand Up @@ -214,9 +214,10 @@ set_mem_limits(State, MemLimit) ->
memory_limit = undefined } ->
error_logger:warning_msg(
"Unknown total memory size for your OS ~p. "
"Assuming memory size is ~pMB.~n",
"Assuming memory size is ~p MiB (~p bytes).~n",
[os:type(),
trunc(?MEMORY_SIZE_FOR_UNKNOWN_OS/?ONE_MB)]);
trunc(?MEMORY_SIZE_FOR_UNKNOWN_OS/?ONE_MiB),
?MEMORY_SIZE_FOR_UNKNOWN_OS]);
_ ->
ok
end,
Expand All @@ -227,18 +228,20 @@ set_mem_limits(State, MemLimit) ->
case get_vm_limit() of
Limit when Limit < TotalMemory ->
error_logger:warning_msg(
"Only ~pMB of ~pMB memory usable due to "
"Only ~p MiB (~p bytes) of ~p MiB (~p bytes) memory usable due to "
"limited address space.~n"
"Crashes due to memory exhaustion are possible - see~n"
"http://www.rabbitmq.com/memory.html#address-space~n",
[trunc(V/?ONE_MB) || V <- [Limit, TotalMemory]]),
[trunc(Limit/?ONE_MiB), Limit, trunc(TotalMemory/?ONE_MiB),
TotalMemory]),
Limit;
_ ->
TotalMemory
end,
MemLim = interpret_limit(parse_mem_limit(MemLimit), UsableMemory),
error_logger:info_msg("Memory limit set to ~pMB of ~pMB total.~n",
[trunc(MemLim/?ONE_MB), trunc(TotalMemory/?ONE_MB)]),
error_logger:info_msg("Memory limit set to ~p MiB (~p bytes) of ~p MiB (~p bytes) total.~n",
[trunc(MemLim/?ONE_MiB), MemLim, trunc(TotalMemory/?ONE_MiB),
TotalMemory]),
internal_update(State #state { total_memory = TotalMemory,
memory_limit = MemLim,
memory_config_limit = MemLimit}).
Expand Down Expand Up @@ -402,9 +405,9 @@ parse_line_sunos(Line) ->
[Value1 | UnitsRest] = string:tokens(RHS, " "),
Value2 = case UnitsRest of
["Gigabytes"] ->
list_to_integer(Value1) * ?ONE_MB * 1024;
list_to_integer(Value1) * ?ONE_MiB * 1024;
["Megabytes"] ->
list_to_integer(Value1) * ?ONE_MB;
list_to_integer(Value1) * ?ONE_MiB;
["Kilobytes"] ->
list_to_integer(Value1) * 1024;
_ ->
Expand Down