Get machine memory in elixir/erlang

You shouldn’t start it directly. You should start the :os_mon application which will start it for you. Generally speaking, always make sure to start an application before invoking any of its modules:

iex(2)> Application.ensure_all_started(:os_mon)
{:ok, [:sasl, :os_mon]}
iex(3)> :memsup.get_system_memory_data
[
  total_memory: 12652220416,
  free_memory: 23302144,
  system_total_memory: 12652220416
]
6 Likes