[erlang-questions] How to see which processes used ets table?
Morgan Segalis
msegalis@REDACTED
Wed Feb 6 01:18:56 CET 2013
Yeah of course, not to use on a production server, I forgot to mention it.
Le 6 févr. 2013 à 01:05, Robert Virding a écrit :
> You have to be a little careful when doing process_info/1/2 on unknown processes. For example if you are worried about the size of message queues then doing process_info(Pid, messages) is not a good idea as it will copy the whole message queue. As in this case using dictionary as it will also copy the dictionary. Process_info() can be very useful but it is one of those BIFs with which you have to exercise care. As is processes() if you have many processes.
>
> Robert
>
>> From: "Morgan Segalis" <msegalis@REDACTED>
>>
>> I have crafted a little function for process monitoring purpose, it
>> might help you, if you're memory issue is process related...
>>
>> Hope it will help
>>
>> [CODE]
>> info() ->
>> get_info(erlang:processes(), dict:new()).
>>
>> get_info([], Dict) ->
>> io:fwrite("Dict: ~p~n", [Dict]);
>> get_info([P|L], Dict) ->
>> case erlang:process_info(P, dictionary) of
>> {dictionary, Info} ->
>> Initial_call = get_dict('$initial_call', Info),
>> Ancestor = get_dict('$ancestors', Info),
>> case dict:find({Initial_call, Ancestor}, Dict) of
>> {ok, Nb} ->
>> IncrNb = Nb + 1;
>> error ->
>> IncrNb = 1
>> end,
>> Dict2 = dict:store({Initial_call, Ancestor}, IncrNb, Dict),
>> get_info(L, Dict2);
>> undefined ->
>> case dict:find(undefined, Dict) of
>> {ok, Nb} ->
>> IncrNb = Nb + 1;
>> error ->
>> IncrNb = 1
>> end,
>> Dict2 = dict:store(undefined, IncrNb, Dict),
>> get_info(L, Dict2)
>> end.
>> [/CODE]
>>
>> Le 5 févr. 2013 à 03:42, Solomon a écrit :
>>
>>> I checked system info with erlang:memory/1 and found the total
>>> amount of memory allocated for ets tables was about 5GB.
>>>
>>> Then I sum the memory size return by ets:i/0 and it was about
>>> 600MB.
>>>
>>> So which processes used ets table and did not return by ets:i/0?
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
More information about the erlang-questions
mailing list