The best practice: do not ever try to catch Throwable or its descendants Error, VirtualMachineError, OutOfMemoryError, and etc.
Never ever. Also, do not swallow InterruptedException in a loop. Few simple rules to avoid hanging application. If we follow these, there will be no question "what is the best way to stop Solr when it gets in OOM” (or just becomes irresponsive because of swallowed exceptions) -- Fuad Efendi 416-993-2060(cell) On February 25, 2016 at 2:37:45 PM, CP Mishra (mishr...@gmail.com) wrote: Looking at the previous threads (and in our tests), oom script specified at command line does not work as OOM exception is trapped and converted to RuntimeException. So, what is the best way to stop Solr when it gets in OOM state? The only way I see is to override multiple handlers and do System.exit() from there. Is there a better way? We are using Solr with default Jetty container. Thanks, CP Mishra