|
|
Subscribe / Log in / New account

The "too small to fail" memory-allocation rule

The "too small to fail" memory-allocation rule

Posted Dec 24, 2014 7:15 UTC (Wed) by ibukanov (subscriber, #3942)
Parent article: The "too small to fail" memory-allocation rule

The fear of untested OOM recovery code reminded me about OOM errors in Java. Formally recovery is possible, but in practice at least in earlier Java those error popping up in arbitrary places could easily lead to unexpected states from which the system could not recover.

What helped on a memory-constrained system was to preallocate a buffer and monitor available memory. When it became low, the buffer was dropped with a global flag set indicating for the application to switch to a recovery mode. In that mode most of normal activities lead to errors. The application remained in it until enough memory was freed to be able to allocate the buffer back.


to post comments

The "too small to fail" memory-allocation rule

Posted Dec 25, 2014 19:07 UTC (Thu) by fw (subscriber, #26023) [Link]

OutOfMemoryError is an VirtualMachineError, not an exception. You can catch it, but the specification about that error says it indicates “the Java Virtual Machine is broken or has run out of resources necessary for it to continue operating”, i.e., VM restart is required. So even formally, you cannot recover from it.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds