Last active
September 13, 2024 15:37
-
-
Save bfolkens/5073a13f15e37d3c34bebcc3ede11e9c to your computer and use it in GitHub Desktop.
Elixir get memory usage by process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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