标签:erlang 进程
在erlang查看占用内存最多的进程,可以用etop,在终端输入下面语句:
spawn(fun() -> etop:start([{output, text}, {interval, 1}, {lines, 20}, {sort, memory}]) end).但etop有时会启动不起来,循环是系统比较繁忙的时候,这时可以用下面的方法:
%%查找最大内存的进程
find_max_memory_process() ->
%%进程列表
ProcessL = processes() -- [self()],
%%获取进程信息,
AttrName = memory,
F = fun(Pid, L) ->
case process_info(Pid, [AttrName, registered_name, current_function, initial_call]) of
[Attr, Name, Init, Cur] ->
Info = {Attr, [{pid, Pid}, Name, Init, Cur]},
[Info | L];
undefined ->
L
end
end,
ProInfoL = lists:foldl(F, [], ProcessL),
%%排序
CompF = fun({A, _},{B, _}) ->
A > B
end,
ProInfoSortL = lists:usort(CompF, ProInfoL),
%%取前10个
Num = 10,
lists:sublist(ProInfoSortL, Num).本文出自 “莫小鹏” 博客,请务必保留此出处http://moxiaopeng.blog.51cto.com/3763412/1542033
erlang中查找占用内存最多的进程,布布扣,bubuko.com
标签:erlang 进程
原文地址:http://moxiaopeng.blog.51cto.com/3763412/1542033