[erlang-questions] eheap_alloc crash when using mnesia

Robert Raschke rtrlists@REDACTED
Tue Oct 21 23:31:06 CEST 2008

On Tue, Oct 21, 2008 at 10:05 PM, Matthew Dempsky <matthew@REDACTED> wrote:
> On Tue, Oct 21, 2008 at 1:07 AM, Robert Raschke <rtrlists@REDACTED> wrote:
>> Beware! With modern kernels it is no longer true that malloc always
>> fails if you run out of memory. Often you'll find it crashes upon
>> access of the allocated memory rather than on the call to malloc().
> To my knowledge, Linux does this but allows you to disable it with a
> run-time kernel setting, and BSD does not.  This understanding seems
> supported at least by PostgreSQL's documentation, which specifically
> calls out Linux's behavior and how to disable it without mentioning
> any other kernels:
> http://www.postgresql.org/docs/8.3/static/kernel-resources.html
> I'll admit to not having thoroughly researched the issue though.  If
> someone can speak more authoritatively, I'm all ears. :-)

Even though you should still check your return value from malloc() and
react accordingly, this does not automatically mean that your program
will be able to do anything usefull in an out of memory situation.
Apart from aborting your program, what would be a sensible thing to do
when you run out of memory? Its not like you would actually be able to
give some mem back to the system and continue. At least not in any
system that I've come across.

In terms of Erlang, we're running in a VM, which I guess would appear
to give the impression of allowing something more "sensible" to
happen. But apart from telling the VM explicitly which processes it is
allowed to abort and which not, in order to reclaim space, what is
possible or desirable? And what kind of behaviour would be

I'd have thought with the Erlang philosophy of "let it crash" we
already have one answer. Turns out it's identical to what most (all?)
OS'es do in this cirumstance.

I'm not sure I would like a popup appearing telling me I'm low on
memory and that I now have to choose whom to get killed. That just
sounds like a "neat" marketing feature to me, rather than something
actually useful in a production setting.


More information about the erlang-questions mailing list