Skip to content

Instantly share code, notes, and snippets.

@ferd
Created July 18, 2013 12:32
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ferd/6028931 to your computer and use it in GitHub Desktop.
Save ferd/6028931 to your computer and use it in GitHub Desktop.
Find Erlang processes that may be leaking refc binaries
f(MostLeaky).
MostLeaky = fun(N) ->
lists:sublist(
lists:usort(
fun({K1,V1},{K2,V2}) -> {V1,K1} =< {V2,K2} end,
[try
{_,Pre} = erlang:process_info(Pid, binary),
erlang:garbage_collect(Pid),
{_,Post} = erlang:process_info(Pid, binary),
{Pid, length(Post)-length(Pre)}
catch
_:_ -> {Pid, 0}
end || Pid <- processes()]),
N)
end.
%% Pairs = MostLeaky(25).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment