问题提出:Erlang服务器100万人在线,16G内存快被吃光。玩家进程占用内存偏高。
解决方法:
第一步:
erlang:system_info(process_count)....,由此确定是进程占用了大量内存
第三步:
查看占用内存最高的进程
>spawn(fun()-> etop:start([{output, text}, {interval, 1}, {lines, 20...第四步:查看占用内存最高的进程状态
>erlang:process_info(pid(0,12571,0))....,233},
{fullsweep_after,65535},
{minor_gcs,0}]},
{suspending,[]}]
其中” {total_heap_size,12538050},”表示占用内存为...总结:
1,服务器编程中,循环一定确保为尾递归;
2,尽量使用OTP,如果使用gen_server替换手写loop,就会避免出现该问题。