[erlang-questions] automatic garbage collection when low memory?

Matthias Lang matthias@REDACTED
Wed Mar 26 17:50:41 CET 2008

Convey Christian J NPRI writes:

 > I've got a program that crashes unless I explicitly call
 > erlang:garbage_collect() at certain points.  I'm pretty sure the
 > problem is that I'm running out of memory simply because the
 > garbage collector isn't running often enough.

 > Does anyone know if there's a way to get Erlang to run the garbage
 > collector when memory gets tight?

I'm at least as pretty sure that there isn't an automatic way to do that.

Your post weakly implies that you think that the GC is run globally,
which is not the case in normal Erlang. GC is on a per-process basis,
on that process' heap. So solving this sort of problem typically
involves identifying which process(es) is(are) the huge one(s).

One thing worth ticking off your list is "do I have lots of memory
in binaries which are no longer referenced but are pointed to from
heaps which haven't been GCed?". You didn't mention binaries, so I'm
guessing not, but I just thought I'd mention it in the hope of
confusing you.


More information about the erlang-questions mailing list