[erlang-questions] how to debug memory leaks?

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Thu Dec 9 01:50:04 CET 2010


On Wed, Dec 8, 2010 at 9:11 PM, Max Lapshin <max.lapshin@REDACTED> wrote:
> I have a bit different situation:
>
> Garbage collection cleans 99% of process memory and top utility shows
> me, that all these gigabytes are freed.
>
> How should I interpret this information? I suppose, that server is
> working not very fast because of high memory consumption and I want to
> lower it.
>

We had this problem in some new io code in etorrent which Magnus Klaar
wrote. There, you could run memory() in a shell and see a very large
binary usage. The problem is that we had a lot of processes which
usually does very little work. They just sit with data. Now, if they
hold references to binaries, these will never be collected, so we sit
with a quite large RSS usage. To fix it, we did two things:

{fullsweep_after, 0} so we nail the whole heap every time.

And an internal timer which triggers after some small idle time (5
seconds currently). This awakens the process and calls
garbage_collect/1. hinbernation is another option for long-waiting
processes.

> Should I call garbage_collect manually or better setup some options
> like fullsweep_after ?

The alternative is to force GC with what you did, but I think it is a
more clunky solution to be honest.


-- 
J.


More information about the erlang-questions mailing list