This discussion is archived
1 Reply Latest reply: May 1, 2012 6:01 AM by jtahlborn RSS

Does Monitoring via JConsole add additional overhead to JVM

user12202994 Newbie
Currently Being Moderated
I have question on Monitoring & Management via JConsole/VisualVM. I understand JConsole provides an efficient way of monitoring and managing remote MBeans residing on a remote JVM, but does it have an additional overhead to the system? Because if we keep JConsole up & running, every 4 seconds it will try to poll the Memory Usage (of Heap/NonHeap and various other Memory Pools..) via JMX connector, and I believe the Memory Usage is calculated on the fly (via native API calls) as opposed to retrieving it from cache. So according to me there should be an additional overhead (may be negligible).

Can experts put some lights...

Also I am curious about what's going on behind the scenes, once we start a remote JVM with com.sun.management.jmxremote argument, it starts the mbean server and open a rmi connector port to start serving client (typically jconsole's) request.
Now 2 things can happen at the time of retrieving and displaying Memory Usage (for example):
Step 1. Jconsole requests the 'Memory Usage' of a Memory Pool
1.1 The request hit the remote MBean Server and retrieves the corresponding MemoryPoolMXBean Object.
1.2 Calls the getUsage() method of the MBean which in turn calls some native API [getUsage0()] to calculate the 'Memory Usage' on the fly and returns the same.

Step 2. Once we start any JVM with JMX param enabled, a background Thread (in Remote JVM) kicks off and every micro second interval it calculates the 'Memory Usage' of all available Memory Pools and stores it in some Data Structure, once JConsole requests the Memory Usage of a Pool..
2.1 The Request hit the remote MBean and retrieves the corresponding MemoryPoolMXBean Object.
2.2 Calls getUsage() method of the MBean which in turn retrieve the most recent Usage from the Data Structure and returns it to the JConsole.

Can anybody tell me which of the above is True?
  • 1. Re: Does Monitoring via JConsole add additional overhead to JVM
    jtahlborn Expert
    Currently Being Moderated
    i haven't seen the actual code which reports the mem usage in the jvm, but i have to imagine the call is cheap. based on my experience using the value to monitor jvms (both remotely and from within the jvm itself) and on the comments in the MemoryMXBean javadocs which indicate that the memory usage values are intended for "monitoring" and "load balancing" type consumption, i would have to imagine that those values are not computed using expensive operations.

    that said, of course there is some additional overhead for monitoring anything in the jvm. you don't get something for nothing. even if the value itself was pre-computed, you are still making method calls and, in the case of remote monitoring, moving bytes over the network (neither of which is free).

    Edited by: jtahlborn on May 1, 2012 9:00 AM

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points