erlang检查内存占用进程
F1 = fun(AttrName, Pid) -> case erlang:process_info(Pid, [AttrName, registered_name,
current_function, initial_call]) of
[{_, Attr}, {registered_name,Name}, Init, Cur] ->
{ok, {Pid, Attr, [Name || is_atom(Name)]++[Init, Cur]}};
undefined ->
{error, undefined}
end end.
F2 = fun(AttrName) -> [Attrs || Pid <- processes() -- [self()],
{ok, Attrs} <- [ F1(AttrName, Pid)]] end.
F3 = fun(AttrName, Num) -> lists:sublist(lists:usort(
fun({_,A,_},{_,B,_}) -> A > B end,
F2(AttrName)
), Num) end.
F3(memory, 10).
[A| _] = F3(memory, 1).
erlang:process_info(erlang:element(1, A), [current_stacktrace]).
浙公网安备 33010602011771号