A DESCRIPTION OF THE REQUEST :
It may be tricky to do this, but when a JVM runs out of memory, it would be a neat trick if a command line switch could tell the VM to simply suspend itself with a warning until enough memory to continue becomes available instead of terminating with an error.
JUSTIFICATION :
This feature could save a lot of time. For example, a processing app might be hours (or days) into a run when it suddenly runs out of memory, needing only an extra 1G to finish. Presently this app will just shut down (via threads throwing OutOfMemoryError) and all those hours of work will be lost. But if it just hung the VM with a warning like:
"Java is paused because it is low on memory, please shut down other applications to continue"
then the application user can potentially shut down other processes (or maybe some jobs just complete on their own on a multi-tenant server), Java autodetects the free memory and continues with no work lost.
Of course there are many complications to halting a VM (network connections or other resources might be lost while the JVM is hung waiting for memory), but the feature would be very useful if it could be implemented.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
JVM pauses when it's out of memory rather than quitting
ACTUAL -
JVM threads terminate with OutOfMemoryError exceptions, possibly causing the process to terminate.
---------- BEGIN SOURCE ----------
This is an RFE
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
This is an RFE