[erlang-questions] Out of memory and garbage collection

Christian <>
Thu Jan 22 13:33:58 CET 2009


2009/1/22 Jeroen Koops <>:
> Hi,
>
> I have a simple question: In Java, it is guaranteed that, before an
> OutOfMemoryException it thrown, all possible garbage collection has been
> done. So, out of memory really means out of memory.
>
> Does a similar guarantee hold for Erlang as well? Or is it possible for the
> system to terminate with an out of memory error while garbage collection
> could have freed more memory?

The later. This article could probably be worth to read:

  http://www.lshift.net/blog/2008/10/31/erlangs-gc-only-runs-when-youre-running

This led to the strategy: "This sounds reasonable - let's try
hibernating after every message and see what happens." in this
article:

  http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-2/

Garbage collection is per-process in the default memory model. As a
strategy, long running processes should probably do only little work
so they can be hibernated, and frequent work should probably be done
in short lived processes so all resources are freed instantly when
they die.



More information about the erlang-questions mailing list