-2

Recently, i have noticed some unsual OutOfMemoryError exceptions in the customer logs and a performance issues. It comes probably from JVM (Heap or stack) that using java 8.

My questions are as follows : 1. how can i get the source of the exception? 2. What's the JVM options should i use (in production)? 3. Should i configure the garbage collector's cycle?

hoss
  • 93
  • 5
  • 1
    You can also use some profiling tools like VisualVM (https://visualvm.github.io/ and included in JDK under JAVA_PATH/bin/jvisualvm.exe). Attach VisualVM to your Java process and do a memory profiling to detect the heaviest allocated objects. – cactuschibre Feb 11 '18 at 09:08
  • 1
    I don't know why this general question has been closed. He just want to know how to get details about this kind of problems. I don't think he can provide details on something he doesn't understand ... – cactuschibre Feb 11 '18 at 09:13
  • @fandango First, asking three questions in one is discouraged on Stackoverflow in general. Second, at least two of them are definitely too broad, and unsolvable as they are asking for options and configuration as if there was a magical “best for every application” configuration. The questioner doesn’t even explain what makes them think that the `OutOfMemoryError`s are “unsual”. – Holger Feb 12 '18 at 08:59

1 Answers1

2
  1. Chasing the source of the exception down can be tough in the case where there is a memory leak. You can configure java to do a heap dump when an OutOfMemoryException happens by adding the -XX:+HeapDumpOnOutOfMemoryError flag to your java command. More details about where the heapdump is stored can be found on this question Using HeapDumpOnOutOfMemoryError parameter for heap dump for JBoss. Then the customer can give you the heapdump next time things crash and you can use a tool like Eclipse MAT to see what objects are consuming memory. This will give you a hint as to what is going on.
  2. It's pretty common to use custom heap sizes. How to do this is described in this question What are the Xms and Xmx parameters when starting JVMs? .
  3. Configuring garbage collection should only be done when you are encountering a performance issue. Since the issue is running out of memory and not performance, I would not recommend changing anything here.
ilooner
  • 1,962
  • 10
  • 24