From 4d6e68e2edae12f613ec6210b84f88d741d8e88b Mon Sep 17 00:00:00 2001 From: huangdan Date: Sun, 31 May 2015 16:27:46 +0800 Subject: [PATCH] memory usage unused --- apps/emqttd/src/emqttd_vm.erl | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/apps/emqttd/src/emqttd_vm.erl b/apps/emqttd/src/emqttd_vm.erl index c083bfda2..4e97e0419 100644 --- a/apps/emqttd/src/emqttd_vm.erl +++ b/apps/emqttd/src/emqttd_vm.erl @@ -71,12 +71,21 @@ scheduler_usage_diff(First, Last) -> ). get_memory()-> - [{Key, get_memory(Key, current)} || Key <- [used, allocated, unused]] ++ erlang:memory(). + [{Key, get_memory(Key, current)} || Key <- [used, allocated, unused, usage]] ++ erlang:memory(). get_memory(used, Keyword) -> lists:sum(lists:map(fun({_, Prop}) -> container_size(Prop, Keyword, blocks_size) - end, util_alloc())). + end, util_alloc())); +get_memory(allocated, Keyword) -> + lists:sum(lists:map(fun({_, Prop})-> + container_size(Prop, Keyword, carriers_size) + end, util_alloc())); +get_memory(unused, Keyword) -> + get_memory(allocated, Keyword) - get_memory(used, Keyword); +get_memory(usage, Keyword) -> + get_memory(used, Keyword) / get_memory(allocated, Keyword). + util_alloc()-> alloc(?UTIL_ALLOCATORS).