summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Majkowski <majek@lshift.net>2010-01-28 11:34:29 -0500
committerMarek Majkowski <majek@lshift.net>2010-01-28 11:34:29 -0500
commit5058c657b7da422741a16be6bdc528fee77c1731 (patch)
treea61146bc997e3912de86245bb33c895b0632f8fc
parent77ea2babf2113458f8f1f01b7dd6afaed657f262 (diff)
downloadrabbitmq-server-5058c657b7da422741a16be6bdc528fee77c1731.tar.gz
bug22266: redefined what memory limit shall mean
-rw-r--r--src/vm_memory_monitor.erl12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/vm_memory_monitor.erl b/src/vm_memory_monitor.erl
index 91788caa..97784015 100644
--- a/src/vm_memory_monitor.erl
+++ b/src/vm_memory_monitor.erl
@@ -218,7 +218,8 @@ get_vm_limit() ->
end.
get_mem_limit(MemFraction, TotalMemory) ->
- lists:min([trunc(TotalMemory * MemFraction), get_vm_limit()]).
+ AvMem = lists:min([TotalMemory, get_vm_limit()]),
+ trunc(AvMem * MemFraction).
%%----------------------------------------------------------------------------
%% Internal Helpers
@@ -254,7 +255,14 @@ get_total_memory({win32,_OSname}) ->
{ok, [_MemLoad, TotPhys, _AvailPhys,
_TotPage, _AvailPage, _TotV, _AvailV], _RestStr} =
io_lib:fread("~d~d~d~d~d~d~d", Result),
- TotPhys;
+ %% Due to erlang bug, on some windows boxes this number is less than zero.
+ %% for example Windows 7 64 bit with 4Gigs of RAM:
+ %% > os_mon_sysinfo:get_mem_info().
+ %% ["76 -1658880 1016913920 -1 -1021628416 2147352576 2134794240\n"]
+ case TotPhys < 1 of
+ true -> unknown;
+ false -> TotPhys
+ end;
get_total_memory({unix, linux}) ->
File = read_proc_file("/proc/meminfo"),