No, really, this is what I'm trying to do. The server supports 1600 users - a long, long process, not a web server, but sometimes users generate more activity than usual, so you need to reduce the load, especially when the "resources", which to a large extent means heap memory, run out. This is a big design question - how to do it?
Perhaps this will be due to the prevention of OOM instead of recovery. Perfectly
if(nearlyOutOfMemory()) throw new MyRecoverableOOMException();
may happen.
But this function nearlyOutOfMemory() I really don't know what could be.
source share