iilyak commented on code in PR #3985:
URL: https://github.com/apache/couchdb/pull/3985#discussion_r876106943


##########
src/couch/src/couch_debug.erl:
##########
@@ -620,6 +635,90 @@ info_size(InfoKV) ->
         {binary, BinInfos} -> lists:sum([S || {_, S, _} <- BinInfos]);
         {_, V} -> V
     end.
+resource_hoggers(MemoryInfo, InfoKey) ->
+    KeyFun = fun
+        ({_Pid, _Id, undefined}) -> undefined;
+        ({_Pid, _Id, DataMap}) -> maps:get(InfoKey, DataMap)
+    end,
+    resource_hoggers(MemoryInfo, InfoKey, KeyFun).
+
+resource_hoggers(MemoryInfo, InfoKey, KeyFun) ->
+    HoggersData = resource_hoggers_data(MemoryInfo, InfoKey, KeyFun),
+    TableSpec = [
+        {50, left, name},
+        {19, centre, InfoKey},
+        {id}
+    ],
+    print_table(HoggersData, TableSpec).
+
+resource_hoggers_data(MemoryInfo, InfoKey, KeyFun) when is_atom(InfoKey) ->
+    resource_hoggers_data(MemoryInfo, InfoKey, KeyFun, 20).
+
+resource_hoggers_data(MemoryInfo, InfoKey, KeyFun, N) when is_atom(InfoKey) ->
+    SortedTuples = resource_hoggers_data(MemoryInfo, InfoKey, KeyFun, 
undefined),

Review Comment:
   The following doesn't terminates (even if I add extra guard)
   
   ```erlang
   MI = couch_debug:memory_info(erlang:processes()).
   couch_debug:resource_hoggers(MI, memory).
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to