@ -1,5 +1,7 @@
- module ( utVMInfo ) .
- include ( " utComMisc.hrl " ) .
- export ( [
vmInfo / 0 % % 打 印 虚 拟 机 简 略 信 息
, processInfo / 1 % % 打 印 进 程 简 略 信 息
@ -15,6 +17,10 @@
, scheduler_usage / 1 % % 统 计 下 1 s每个调度器CPU的实际利用率 ( 因 为 有 spin wait 、 调 度 工 作 , 可 能 usage 比 top显示低很多 ) \
, scheduler_stat / 0 % % 统 计 下 1 s内调度进程数量 ( 含 义 : 第 一 个 数 字 执 行 进 程 数 量 , 第 二 个 数 字 迁 移 进 程 数 量 )
, scheduler_stat / 1 % % 统 计 下 1 s内调度进程数量 ( 含 义 : 第 一 个 数 字 执 行 进 程 数 量 , 第 二 个 数 字 迁 移 进 程 数 量 )
, memInfoInit / 2
, memInfoPrint / 3
, test / 0
] ) .
% % 打 印 虚 拟 机 简 略 信 息
@ -457,4 +463,36 @@ get_processes() ->
io : fwrite ( " process count: ~p ~n ~p value is large than ~p count: ~p ~n Lists: ~p ~n " ,
get_process_info_and_large_than_value ( memory , 0 ) ) .
memInfoInit ( CurModule , CurLine ) - >
erlang : put ( ? pdMemInfo , { CurModule , CurLine , erlang : system_time ( nanosecond ) , recon : info ( self ( ) , memory_used ) } ) .
memInfoPrint ( CurModule , CurLine , Threshold ) - >
case erlang : get ( ? pdMemInfo ) of
undefined - >
erlang : put ( ? pdMemInfo , { CurModule , CurLine , erlang : system_time ( nanosecond ) , recon : info ( self ( ) , memory_used ) } ) ;
{ OldModule , OldLine , OldTime , OldMemInfo } - >
CurMemInfo = recon : info ( self ( ) , memory_used ) ,
CurTime = erlang : system_time ( nanosecond ) ,
erlang : put ( ? pdMemInfo , { CurModule , CurLine , CurTime , recon : info ( self ( ) , memory_used ) } ) ,
OldUsed = element ( 2 , lists : nth ( 1 , element ( 2 , OldMemInfo ) ) ) ,
CurUsed = element ( 2 , lists : nth ( 1 , element ( 2 , CurMemInfo ) ) ) ,
Sub = CurUsed - OldUsed ,
case erlang : abs ( Sub ) > = Threshold of
true - >
io : format ( " IMY*********Memory use changes are too large ~n ~p ~n ~p ~n ~p ~n ~p ~n " , [ { addOrSub , Sub } , { timeDiff , CurTime - OldTime } , { old , OldModule , OldLine , OldTime , OldMemInfo } , { cur , CurModule , CurLine , CurTime , OldMemInfo } ] ) ;
_ - >
ignore
end
end .
test ( ) - >
? MII ( ) ,
? MIP ( 0 ) ,
? MIP ( 0 ) ,
? MIP ( 0 ) .