4

As the title states, how much overhead does jmap -histo and jmap -heap bring to a jvm respectively?

If a memory sensitive Java process is at the edge of OutOfMemory (e.g around 96% of heap is full, and can't be cleared by full gc), is it possible for one of the operations to bring the jvm to OutOfMemory?

Eric
  • 22,183
  • 20
  • 145
  • 196

1 Answers1

7

jmap -histo and jmap -heap work differently: jmap -histo uses Dynamic Attach Mechanism, and jmap -heap works through HotSpot Serviceability Agent. The difference is described here.

Therefore, jmap -histo is executed by JVM itself, but jmap -heap runs in a tool process while JVM process is suspended. In both cases no new Java objects are created, the tool will not cause OutOfMemoryError.

In both cases application threads are stopped: jmap -histo stops Java threads, and jmap -heap stops the whole JVM process. The duration of the pause can be rather long especially for large heaps. E.g. it may take several seconds to walk through 4GB heap.

Community
  • 1
  • 1
apangin
  • 92,924
  • 10
  • 193
  • 247
  • Any idea whether [`jcmd GC.class_histogram`](https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr006.html) approach has the same impact? – andyfeller Nov 12 '19 at 15:55
  • @andyfeller `jcmd GC.class_histogram` works exactly like `jmap -histo` – apangin Nov 12 '19 at 15:59