JDK-8181463 : Eliminate OutOfMemoryError with command line switch
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 9
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2017-06-01
  • Updated: 2017-06-07
  • Resolved: 2017-06-07
Related Reports
Relates :  
Description
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


Comments
This is a request for a quite big change with very limited benefits [1]. Probably this request would be complaining about the difficulty of finding the proper Max Java Heap (-Xmx). If it is the case, fortunately we already have CR for 'Dynamically sized heap (JDK-6990484)' [1]: Currently we are allocating(reserving) a whole heap at the beginning but this request is allocating more than that which potentially conflicts with other options(e.g. -Xmx). Or it would meant chunking allocation but it has drawback(https://bugs.openjdk.java.net/browse/JDK-4408373?focusedCommentId=12549030&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12549030). Even though we have this feature, there is no guarantee that VM will continue working without any problem due to an application layer problem(e.g. network connection timeout etc..) In addition, VM can't know how many heap are required to solve the situation. If the newly added heap doesn't help solve the situation, VM has to repeat additional allocation which increases an application layer problem higher. Eventually this lowers the benefit of this request.
07-06-2017