1

From the linux journal file, the "java.lang.OutOfMemoryError: Direct buffer memory" exception was logged. How do I catch the exception, so that I can create a heap dump of my java process? I will also need to know how I can restart the java program when exception occurs. However, I will post another question for that. By the way, the Java tool option, " -XX:+HeapDumpOnOutOfMemoryError", does not create a heap dump on direct memory exceptions.

Sep 20 23:02:55 CKM01204505062-A control-path[128819]: 2021-09-20 23:02:55.266 [] [INFO] [com.emc.bedrock.http.HttpVerticle|vert.x-eventloop-thread-3]  Request ID: 2c7633a4-db9c-4ec5-b4ca-c93c47512384 completed in 4 ms.
Sep 20 23:02:55 CKM01204505062-A control-path[128199]: Exception in thread "iothread-2" java.lang.OutOfMemoryError: Direct buffer memory
Sep 20 23:02:55 CKM01204505062-A control-path[128199]:         at java.nio.Bits.reserveMemory(Bits.java:695)
Sep 20 23:02:55 CKM01204505062-A control-path[128199]:         at java.nio.DirectByteBuffer.(DirectByteBuffer.java:123)
Sep 20 23:02:55 CKM01204505062-A control-path[128199]:         at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311)
Sep 20 23:02:55 CKM01204505062-A control-path[128199]:         at zmq.DecoderBase.(DecoderBase.java:35)
Sep 20 23:02:55 CKM01204505062-A control-path[128199]:         at zmq.V1Decoder.(V1Decoder.java:21)
Sep 20 23:02:55 CKM01204505062-A control-path[128199]:         at zmq.StreamEngine.newDecoder(StreamEngine.java:102)
Sep 20 23:02:55 CKM01204505062-A control-path[128199]:         at zmq.StreamEngine.handshake(StreamEngine.java:549)
Sep 20 23:02:55 CKM01204505062-A control-path[128199]:         at zmq.StreamEngine.inEvent(StreamEngine.java:278)
Sep 20 23:02:55 CKM01204505062-A control-path[128199]:         at zmq.IOObject.inEvent(IOObject.java:86)
Sep 20 23:02:55 CKM01204505062-A control-path[128199]:         at zmq.Poller.run(Poller.java:228)
Sep 20 23:02:55 CKM01204505062-A control-path[128199]:         at java.lang.Thread.run(Thread.java:748)
  • 1
    It's not an [Exception](https://docs.oracle.com/javase/7/docs/api/java/lang/Exception.html), it's an [Error](https://docs.oracle.com/javase/7/docs/api/java/lang/Error.html). Catching an error is generally not a good idea, though can be useful in certain circumstances if carefully done. – user16632363 Oct 13 '21 at 01:29
  • You don't catch the exception, or do similar in your application because there is no way to trigger the dump creation from application code in the JVM. Instead you set JVM options on the command line. The real answer is in the duplink (that you found!). – Stephen C Oct 13 '21 at 01:58
  • This question is not answered in https://stackoverflow.com/questions/2787976/how-to-generate-thread-dump-java-on-out-of-memory-error?rq=1. While the OOM is related to Direct buffer memory, VM flags are not catching it. I have checked it in JDK 11 – Vinto Dec 07 '21 at 09:02

1 Answers1

0

Actually, I found answer to detecting direct memory out of memory exception at : how to generate thread dump java on out of memory error

  • If you find the answer and it is essentially another Q&A, either delete your question or write an answer that particularizes the answer for your specific situation. An answer that just links to another Q&A without adding anything specific or new is a poor answer and a waste of everyone's time. (And answers like this are routinely deleted in review as a "link only answers") – Stephen C Oct 13 '21 at 02:04