2
|
1 |
VerboseGC demonstrates the use of the java.lang.management API to
|
|
2 |
print the garbage collection statistics and memory usage remotely
|
|
3 |
by connecting to a JMX agent with a JMX service URL:
|
|
4 |
service:jmx:rmi:///jndi/rmi://<hostName>:<portNum>/jmxrmi
|
|
5 |
where <hostName> is the hostname and <portNum> is the port number
|
|
6 |
to which the JMX agent will be connected.
|
|
7 |
|
|
8 |
To run the VerboseGC demo
|
|
9 |
|
|
10 |
(1) Start the application with the JMX agent - here's an example of
|
|
11 |
how the Java2D is started
|
|
12 |
|
|
13 |
java -Dcom.sun.management.jmxremote.port=1090
|
|
14 |
-Dcom.sun.management.jmxremote.ssl=false
|
|
15 |
-Dcom.sun.management.jmxremote.authenticate=false
|
|
16 |
-jar <JDK_HOME>/demo/jfc/Java2D/Java2Demo.jar
|
|
17 |
|
|
18 |
This instruction uses the Sun's built-in support to enable a JMX agent.
|
|
19 |
You can programmatically start a JMX agent with the RMI connector
|
|
20 |
using javax.management.remote API. See the javadoc and examples for
|
|
21 |
javax.management.remote API for details.
|
|
22 |
|
|
23 |
(2) Run VerboseGC
|
|
24 |
|
|
25 |
java -jar <JDK_HOME>/demo/management/VerboseGC/VerboseGC.jar localhost:1090
|
|
26 |
|
|
27 |
These instructions assume that this installation's version of the java
|
|
28 |
command is in your path. If it isn't, then you should either
|
|
29 |
specify the complete path to the java command or update your
|
|
30 |
PATH environment variable as described in the installation
|
|
31 |
instructions for the Java(TM) SDK.
|