Hacker News new | past | comments | ask | show | jobs | submit login

I have and it wasn't good. It is impossible to handle out of memory exceptions inside the BEAM. At best, you can hope for a crash of the VM. At worse, it just hangs. And one will most likely not find out about this until they hit this scenario.



Interesting, definitely worth knowing beforehand (I was thinking of implementing a small service that could be pretty memory-intensive using Elixir.) I wonder if there's a way to try and manage memory to avoid ENOMEM.


If BEAM is allocating memory it must either be copying a message from one process to another, allocating space in a process for its stack, or for some bookkeeping like to spawn a new process. In the first two cases why doesn't it just kill the process and send the usual link and monitor messages to let other Erlang processes handle the failure?


How would it send a message if it can't allocate memory anymore?


Haha, yeah, that's the problem with ENOMEM handling in general: unless you have a very clear path to free memory immediately and then try to do some reasonable cleanup, you are screwed. Back in the bad old days of running Windows machines with 8mb of memory, I'd religiously handle that kind of error code... but I can't recall the last time I actually bothered. Commoditized hardware makes us lazy.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: