views:

213

answers:

3

I'm using ejabberd + mochiweb on our server. The longer I keep ejabberd and mochiweb running, the more memory is consumed (last night it was consuming 35% of memory. right now it's a bit above 50%). I thought this was just a mnesia garbage collection issue - so I installed Erlang R13B3 and restarted ejabberd. This didn't fix it though.

So I'm noticing now that at a bit above 50% of full memory consumption, it looks like ejabberd's starting to "let go" of memory and stay at around 50%. Is this normal? Is ~50% a threshold for ejabberd, so that when it reaches it it says, "hey time to actually let some memory go..." and maybe it keeps the rest around for quick access (like caching mnesia?)

I appreciate any input. Thanks!

+1  A: 

Run erlang:memory(). in your shell every now and then. You can also give erlang:system_info(Type). with allocated_areas and allocator a try. These should give you a hint on what kind of memory is leaking.

You can also setup memsup to warn you about processes allocating too much memory.

Zed
erlang:memory() shows me using ~30MB. (top shows ~1.0GB right now.) I noticed that at one point today, the memory "flushed" down and around 300MB freed up. I have no idea where this memory is held at, but I think ejabberd/erlang is freeing it up somehow when it "needs" to. Could this also be because I'm running ejabberd 2.1.0 on Erlang R13B03?
ewindsor
correction: top shows ~1.0GB of TOTAL memory used, but erlang is only using 2.0% of 1.7GB. The numbers in TOP do not add up. I haven't had to reset ejabberd, and the total memory doesn't seem to crawl beyond 1.0GB. (it fluctuates ~20MB). I have 2 processes that execute each minute to "clean up" and "reorganize" things. I read that ejabberd does a hibernate on some processes only when it's been idle for 3 minutes. Could this have something to do with it?
ewindsor
A: 

Newly created atoms in erlang processes get never garbage collected. This might be an issue when processes are registered by an algorith that creates atom names from random eg. randomly created strings.

Johann Höchtl
A full atom table would kill the VM, so there would be a clear indication of this.
Zed
A: 

Turns out, there is no memory leak (yay!) Ejabberd is taking up only < 40MB. Finally I saw the light when I saw the Usage Graphs on EngineYard - only 288MB is actually being used, 550MB is being buffered, and 175MB is being cached. My ejabberd server an update every 2.5 seconds from each client so that may explain why so much is being buffered/cached.

Thanks for all of your help.

ewindsor