I have a critical process running in java (1.6), with a registered stop hook. In some cases, when I get a problem with OOM (more about this problem below), the process abruptly stops, I do not receive any of my logs, my catch (Throable x) does not catch an exception.
But the disconnect hook works. Therefore, if there was a way to find out that the process would be completed due to some unpleasant OOM, I can write down the necessary information before exiting.
Is there any way to do this?
About OOM : Not sure what the exception is, because, as I said, it does not fall. I know this is OOM because I am starting the process with
-XX:+HeapDumpOnOutOfMemoryError
and I get a heap dump file. In other cases, the exception was caught and the limit exceeded ava.lang.OutOfMemoryError: GC. But I'm not sure that this is always the case.
EDIT:
If this is not clear: I am not trying to prevent OOM, as this may happen for good reason in some scenario, I just want to make sure that this is clear in the application log files
My question is : is it possible to find out that the process terminates due to OOM during the stop?
I need to do programmatically and from the same process .
- , java_pid_pid process_.hprof( pid) OOM.
, Runtime.getRuntime(). FreeMemory() , , , , , , , , .