Erlang如何查找内存消耗过高原因
2016-12-24 14:26
267 查看
查看进程数目是否正常? erlang:system_info(process_count). 进程数目合理
第二步:
查看节点的内存消耗在什么地方?
> erlang:memory().
[{total,2099813400},
{processes,1985444264},
{processes_used,1985276128},
{system,114369136},
{atom,4509545},
{atom_used,4507777},
{binary,22756952},
{code,10486555},
{ets,50948808}]
显示内存大部分消耗在进程上,由此确定是进程占用了大量内存
第三步:
查看哪些进程占用内存最高?
> spawn(fun() -> etop:start([{output, text}, {interval, 1}, {lines, 20}, {sort, memory}]) end).
(以输出text方式启动etop,其间隔为1秒,输出行数为20行,按照内存排序. 这里spawn一个新进程,目的是输出etop数据时不影响erlang shell 输入.)
etop输出有点乱,超过一定范围变成了**.
第四步:
查看占用内存最高的进程状态
> erlang:process_info(pid(0,12571,0)).
[{current_function,{mod_player,send_msg,2}},
{initial_call,{erlang,apply,2}},
{status,waiting},
{message_queue_len,0},
{messages,[]},
{links,[<0.12570.0>]},
{dictionary,[]},
{trap_exit,false},
{error_handler,error_handler},
{priority,normal},
{group_leader,<0.46.0>},
{total_heap_size,12538050},
{heap_size,12538050},
{stack_size,10122096},
{reductions,3795950},
{garbage_collection,[{min_bin_vheap_size,46368},
{min_heap_size,233},
{fullsweep_after,65535},
{minor_gcs,0}]},
{suspending,[]}]
其中” {total_heap_size,12538050},” 表示占用内存为 12358050 words(32位系统word size为4,64位系统word size为8, 可以通过erlang:system_info(wordsize) 查看),在64位系统下将近100M, 太夸张了!
相关文章推荐
- 如何查找.NET程序内存不断上涨的原因(CLRProfiler)
- 如何查找.NET程序内存不断上涨的原因(CLRProfiler)
- 如何查找.NET程序内存不断上涨的原因
- 如何查找.NET程序内存不断上涨的原因(CLRProfiler)
- 如何查找.NET程序内存不断上涨的原因(CLRProfiler)
- 如何查找.NET程序内存不断上涨的原因(CLRProfiler)
- 线上CPU很高、内存占用很少,如何快速查找到原因?
- vc6.0中如何查找内存泄露
- 如何查找内存泄露
- 用一行代码让w3wp进程崩溃,如何查找w3wp进程崩溃的原因
- 用一行代码让w3wp进程崩溃,如何查找w3wp进程崩溃的原因
- [MySQL优化] -- 如何查找SQL效率低的原因
- 如何处理消耗大内存的后台任务(线程池)WorkEngine
- 如何查看系统内存的消耗情况?(AIX-内存笔记01)
- Oracle进程内存结构-如何察看Oracle进程消耗的内存
- Oracle进程内存结构-如何察看Oracle进程消耗的内存
- Android中如何查找内存泄露
- [原创]如何使用新版HooKlogger查找内存泄露(3版)
- Oracle进程内存结构-如何察看Oracle进程消耗的内存
- 如何察看Oracle进程消耗的内存