Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Finding leaked processes in Erlang
lists:sort(fun({_, X}, {_, Y}) -> X > Y end,
dict:to_list(lists:foldl(
fun(Pid, Dict) ->
InitialCall = case erlang:process_info(Pid, initial_call) of
{initial_call,{proc_lib,init_p,A}} ->
case erlang:process_info(Pid, dictionary) of
{dictionary, D} -> proplists:get_value('$initial_call', D, undefined);
_ -> {proc_lib,init_p,A}
end;
{initial_call,{erlang,apply,A}} ->
case erlang:process_info(Pid, current_function) of
{current_function,MFA} -> MFA;
_ -> {erlang,apply,A}
end;
{initial_call,IC} ->
IC;
Other ->
Other
end,
dict:update_counter(InitialCall, 1, Dict)
end, dict:new(), erlang:processes()))).
@loxs

This comment has been minimized.

Copy link

@loxs loxs commented Mar 24, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment