-
-
Save irr/74072d4ca649aa5abfd8 to your computer and use it in GitHub Desktop.
Finding leaked processes in Erlang
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
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,IC} -> | |
IC; | |
Other -> | |
Other | |
end, | |
dict:update_counter(InitialCall, 1, Dict) | |
end, dict:new(), erlang:processes()))). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment