diff --git a/base/sysinfo.jl b/base/sysinfo.jl index f0852f32fc17d..c8214a86150f1 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -20,6 +20,7 @@ export BINDIR, loadavg, free_memory, total_memory, + physical_memory, isapple, isbsd, isdragonfly, @@ -257,8 +258,25 @@ free_memory() = ccall(:uv_get_free_memory, UInt64, ()) Sys.total_memory() Get the total memory in RAM (including that which is currently used) in bytes. +This amount may be constrained, e.g., by Linux control groups. For the unconstrained +amount, see `Sys.physical_memory()`. """ -total_memory() = ccall(:uv_get_total_memory, UInt64, ()) +function total_memory() + memory = ccall(:uv_get_constrained_memory, UInt64, ()) + if memory == typemax(UInt64) + return physical_memory() + else + return memory + end +end + +""" + Sys.physical_memory() + +Get the total memory in RAM (including that which is currently used) in bytes. The entire +amount may not be available to the current process; see `Sys.total_memory()`. +""" +physical_memory() = ccall(:uv_get_total_memory, UInt64, ()) """ Sys.get_process_title()