diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/vm_memory_monitor.erl | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/vm_memory_monitor.erl b/src/vm_memory_monitor.erl index 91788caae8..9778401513 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"), |
