2

Memory Analysers (Instrumentation and Monitoring tools) like VisualVM and jProfiler connect to Java Application's JVM though JMX extensions (though there might be other means to connect - like jstatd etc, i have seen JMX is quite common)

My Understanding About JMX:
By default JMX must expose its default port(not sure if there is a default port number) so that Memory Analysers can connect. So, I assume that when more than one java apps are running with default JMX config, on the same machine, there must be a JMX port conflict.

But I have never noticed that. I have seen java apps running happily with default configs and Mem Analysers could happily connect with each of these java apps at the same time. So my understanding about JMX ports is not entirely correct. Could some one say how more than one java app is able to expose JMX functionality with default configurations at the same time on the same machine. (???? is a random port used by JMX for each java application????)

  • Hi Joveny, wellcome to SO. I think that you should read this thread. You can define the imx port using a flag. https://stackoverflow.com/questions/10331189/how-to-find-the-default-jmx-port-number/10368260 – aironman Sep 03 '20 at 19:05

1 Answers1

1

Tools like VisualVM use JMX together with Dynamic Attach mechanism to monitor local Java Virtual Machines.

  1. First, the tool connects to a local JVM via Attach API.
  2. Then it executes (also via Attach API) a command to start Management Agent (JMX server) in the target JVM.
  3. The target JVM starts Management Agent on some free port and sets the opened port value in the Agent properties.
  4. The tool uses Attach API again to read Agent properties, and thus discovers the port the Agent listens to.
  5. Then it establishes the JMX connection to the Management Agent on this port.

Obviously, different local JVMs start Management Server on different ports, but VisualVM discovers the port number via Dynamic Attach.

apangin
  • 92,924
  • 10
  • 193
  • 247