Skip to content

Commit

Permalink
Expose constrained memory as Sys.total_memory; add Sys.physical_memory.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Sep 16, 2022
1 parent 3a34293 commit bef691c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion base/sysinfo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export BINDIR,
loadavg,
free_memory,
total_memory,
physical_memory,
isapple,
isbsd,
isdragonfly,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit bef691c

Please sign in to comment.