aspose file tools*
The moose likes Performance and the fly likes Does Monitoring via JConsole add additional overhead to JVM Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Does Monitoring via JConsole add additional overhead to JVM" Watch "Does Monitoring via JConsole add additional overhead to JVM" New topic
Author

Does Monitoring via JConsole add additional overhead to JVM

Rudraksh Kreshak
Greenhorn

Joined: Apr 25, 2012
Posts: 4
All,

I am a newbie, 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 Memory Pools, etc) 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...
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2771
    
  10

Yes, of course it will have some impact. However, here's an article that says it's only about 3%.
Rudraksh Kreshak
Greenhorn

Joined: Apr 25, 2012
Posts: 4
That was what I guessed too..

But my second question, does remote Mbean calculates Memory usage at the time it receives a request from JConsole (i.e., on the fly by calling some native API), or the Memory Usage(s) are being calculated and stored in the background in some data structure at a regular interval, and whenever the MBean (MemoryPoolMXBean) receives a request from JConsole, it retrieves the latest Usage and return it back to JConsole.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
I think the more important question is: does it have an impact that is noticeable to users? Most JVMs do not run at maximum CPU load, so even if monitoring has an overhead, users may not notice it. And if by monitoring a live system you figure out a performance problem and subsequently fix it, then that's going to help users a lot more than the overhead of monitoring takes form them while it's going on. (Presumably you would not have the JMX monitoring run at all times.)
Rudraksh Kreshak
Greenhorn

Joined: Apr 25, 2012
Posts: 4
Thanks Tom, however, I was 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):
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.

2. Once we start any JVM with JMX param enabled, a background Thread 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.

I guess its the former one which takes place.
Chris Hurst
Ranch Hand

Joined: Oct 26, 2003
Posts: 396

This was actually with Visual VM (new JConsole ;-) )..

At one point I was debugging memory usage reported on an application and I had the app at zero load but no there was all this memory being used ... of course it turned out it was the fact I was watching that was causing the memory churn due to its RMI connection ;-)


"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5
Rudraksh Kreshak
Greenhorn

Joined: Apr 25, 2012
Posts: 4
Thanks Chris for your reply.
But which one of the below 2 Steps is true.

Step A:
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 B:
2. Once we start any remote JVM with JMX param enabled, a background Thread (in the 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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Does Monitoring via JConsole add additional overhead to JVM
 
Similar Threads
Heap usage increases without web-app usage
Is this a memory leak condition ?
Jboss 4.2.3 JVM Monitoring
jconsole to monitor server's VM args from windows client
How to read memory usage for process running in Linux,