Skip to content

Instantly share code, notes, and snippets.

@snaiper80
Forked from ferd/refc_leak.erl
Created October 30, 2015 06:46
Show Gist options
  • Save snaiper80/16e4d448d48c34703b76 to your computer and use it in GitHub Desktop.
Save snaiper80/16e4d448d48c34703b76 to your computer and use it in GitHub Desktop.

Revisions

  1. @ferd ferd created this gist Jul 18, 2013.
    16 changes: 16 additions & 0 deletions refc_leak.erl
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    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).