Jvm: is it possible to find out that the process terminates due to OOM during a stop?

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() , , , , , , , , .

+5
7

OOM , , JVM , - , OOM.

. .

+3

, , OOE ( , ), .

, Unix Windows .

?

jvisualvm -

+2
+1

() OutOfMemoryErrors, , catch, .

, (1) OOM, (2) (System.gc()) - . , .

0

, .

, . , , , .

, , SO: java.lang.OutOfMemoryError: GC - it , .

0

, jvisualvm (JDK 6 bin), , - , , , OOM , , POC (. )

Java, OOM?

You can catch what result is sent to the output stream of the called process and see if there is a sequential sequence of exit / stack code that you can use to identify OOM

I'm sure there are more approaches, but this seems like a good, software starting point.

0
source

All Articles