Hacker News new | past | comments | ask | show | jobs | submit login
Why didn’t my app throw an OutOfMemoryError? (2014) (java.net)
18 points by luu on June 13, 2015 | hide | past | favorite | 4 comments



OutOfMemoryErrors are pretty nasty. I've seen many cases where they are delivered on some random background worker thread where it isn't properly handled, thus often leaving an app in a "zombie state" where it thinks all is fine but doesn't process new incoming connections, for example. Because it didn't notice the thread just dying. IIRC the conventional wisdom is that when you get an OutOfMemoryError, all bets are off and you should really just terminate the process.

Another thing that's always been bothersome is how the JVM is such a poor citizen regarding memory use alongside multiple other processes. You often have to configure a high hard memory limit -Xmx to be able to handle mem usage spikes, but more often than not this memory is never returned to the operating system (even though maybe the contents of it has been internally recycled by the garbage collector).

Maybe things have changed recently, but at least in the mid 2000s this was a huge hassle when you wanted to host multiple app servers on the same box. Never had the same problem virtualhosting apps written in other languages.


I've seen plenty of poorly written Java applications that have background threads terminate due to poor exception handling with that exact end result.

However, is there a mechanism other than catching OutOfMemoryError/Throwable and swallowing the exception that can cause that behavior?


Yes unfortunately I've seen this quite a lot, especially with buggy software and EE app servers.

This masks an actual problem - often resulting in slower and slower performance as the system starts to swap. As author points out, it'd be better if you'd fail fast with an OutOfMemoryError rather than postponing it and sacrificing usability of the system.


OutOfMemory is hard to field, because, of course, the handler may need memory. A friend likens them to putting an altimeter on his car, so if he drives off a cliff he will know how far it is to the ground.




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

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

Search: