Last active
March 25, 2017 00:54
-
-
Save rlipscombe/a8e87583d47799170f8b to your computer and use it in GitHub Desktop.
Finding leaked processes in Erlang
This file contains 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,{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()))). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Elixir Version: https://gist.github.com/loxs/f38588d1d1c098745624960ebad60e25