[erlang-questions] Out of memory and garbage collection
Thu Jan 22 13:49:09 CET 2009
Interesting, and consistent with what I'm seeing. I have an application that
spawns a few thousand gen_servers. Each server instance initializes itself
with a couple of mnesia queries, which may produce a lot of temporary data.
The data that is eventually used as the gen_server's state is very limited,
In my test-setup, after initialization, the gen_server's just sit idle, and
indeed seem to hang on to all heap-memory needed during initialization,
leading to an out-of-memory error after creating only a few hundred
processes. This is solved by forcing a garbage collection right after
initialization, and probably also by using the fullsweep_after spawn option
(which I still have to look into).
On Thu, Jan 22, 2009 at 1:33 PM, Christian <> wrote:
> 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
> > 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:
> This led to the strategy: "This sounds reasonable - let's try
> hibernating after every message and see what happens." in this
> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions