Skip to content

Instantly share code, notes, and snippets.

@bfolkens
Last active December 3, 2018 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bfolkens/5073a13f15e37d3c34bebcc3ede11e9c to your computer and use it in GitHub Desktop.
Save bfolkens/5073a13f15e37d3c34bebcc3ede11e9c to your computer and use it in GitHub Desktop.
Elixir get memory usage by process
defmodule ProcExtras do
def list() do
Process.list()
|> Enum.map(fn (x) -> [initial_call: {c, _, _}, total_heap_size: s, message_queue_len: m] = Process.info(x, [:initial_call, :total_heap_size, :message_queue_len]); [c, x, s, m] end)
|> Enum.sort(fn [_ , _, sa, _], [_, _, sb, _] -> sa >= sb end)
|> Enum.take(20)
|> Enum.each(fn [c, x, s, m] -> IO.puts("#{inspect x}\t#{s}\t#{m}\t#{c}") end)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment