3
votes

I am running ejabberd 2.1.10 server on Linux (Erlang R14B 03). I am creating XMPP connections using a tool in batches and sending message randomly. ejabberd is accepting most of the connections. Even though connections are increasing continuously, value of erlang:memory(total) is observed to be with-in a range.
But if I check the memory usage of ejabberd process using top command, I can observe that memory usage by ejabberd process is increasing continuously.

I can see that difference between the values of erlang:memory(total) and the memory usage shown by top command is increasing continuously.

Please let me know the reason for the difference in memory shown. Is it because of memory leak? Is there anyway I can debug this issue? What for the additional memory (difference between the erlang & top command) is used if it is not memory leak?

1

1 Answers

2
votes

A memory leak in either the Erlang VM itself or in the non-Erlang parts of ejabberd would have the effect you describe. ejabberd contains some NIFs - there are 10 ".c" files in ejabberd-2.1.10.

Was your ejabberd configured with "--enable-nif"? If so, try comparing with a version built using "--disable-nif", to see if it has different memory usage behaviour.

Other possibilities for debugging include using Valgrind for detecting and locating the leak. (I haven't tried using it on the Erlang VM; there may be a number of false positives, but with a bit of luck the leak will stand out, either by size or by source.)

A final note: the Erlang process's heap may have been fragmented. The gaps among allocations would count towards the OS process's size; It doesn't look like they are included in erlang:memory(total).