Skip to content
Permalink
Browse files
[bug_fix] bin_leak/1 should absolute value rank
  • Loading branch information
zhongwencool committed Aug 9, 2016
1 parent a3dd139 commit 0f53a75eb4e9372191fa5045bf72cc08174e568c
Showing 2 changed files with 12 additions and 9 deletions.
@@ -311,15 +311,17 @@ proc_window(AttrName, Num, Time) ->
%% for more details on refc binaries
-spec bin_leak(pos_integer()) -> [proc_attrs()].
bin_leak(N) ->
sublist_top_n([try
{ok, {_,Pre,Id}} = recon_lib:proc_attrs(binary, Pid),
erlang:garbage_collect(Pid),
{ok, {_,Post,_}} = recon_lib:proc_attrs(binary, Pid),
{Pid, length(Post)-length(Pre), Id}
catch
_:_ -> {Pid, 0, []}
end || Pid <- processes()],
N).
Procs = sublist_top_n([try
{ok, {_,Pre,Id}} = recon_lib:proc_attrs(binary, Pid),
erlang:garbage_collect(Pid),
{ok, {_,Post,_}} = recon_lib:proc_attrs(binary, Pid),
Val = length(Post)-length(Pre),
{Pid, {abs(Val), Val}, Id}
catch
_:_ -> {Pid, {0, 0}, []}
end || Pid <- processes()],
N),
[{Pid, Val, Id} ||{Pid, {_, Val}, Id} <-Procs].

%% @doc Shorthand for `node_stats(N, Interval, fun(X,_) -> io:format("~p~n",[X]) end, nostate)'.
-spec node_stats_print(Repeat, Interval) -> term() when
@@ -127,6 +127,7 @@ bin_leak(_Config) ->
Res = recon:bin_leak(5),
5 = length(Res),
true = proc_attrs(Res),
true = lists:any(fun({_,Val,_})-> Val =/= 0 end, Res),
%% all results are =< 0, and ordered from smallest to biggest
lists:foldl(fun({_,Current,_}, Next) when Current =< Next -> Current end,
0,

0 comments on commit 0f53a75

Please sign in to comment.