Java VM memory monitoring

Source: Internet
Author: User

Sun hotspot JVM

Java version "1.6.0 _ 12"

 

I. VM parameter Methods

1.-verbose: GC

It will print the status of each GC execution. [the space occupied by the objects before GC is performed-> the space occupied by objects that cannot be cleared after GC (the available space of HEAP ), GC execution time] 2.-XX: + printgcdetails prints more detailed information.

[GC [defnew: space occupied by young generation activity objects before GC execution-> after GC, YG cannot clear space occupied by objects (YG available space ), execution time] heap occupied space before execution-> heap occupied space after execution (heap available space), overall execution time] 3.-XX: + printgctimestamps prints the GC execution time. 4.-XX: minheapfreeratio = Minimum heap available space percentage. When the available heap space is less than this percentage, the heap space of the generation increases, to meet this percentage 5,-XX: maxheapfreeratio = maximum heap available space percentage when the available space percentage exceeds this value, the heap space of the generation will be reduced, to meet this percentage 6,-XMS minimum heap space 7,-xmx maximum heap space 8,-XX: newratio = n indicates young generation and tenured Ge The ratio of neration is 1: Minimum,-XX: newsize = minimum space of Young Generation 10,-XX: maxnewsize = maximum space of young generation 11,-XX: when vorratio = the ratio of the n1_vor region to the Eden region is 1: n12,-XX: + useparallelgc using throughput collector13,-XX: parallelgcthreads = number of threads used by throughput collector 2. Command 1. JPS is similar to PS on Unix. It is used to display local Java processes. You can check that several Java programs are running locally, and display their process Number 2, jinfo can output and modify the VM parameters of the running Java program. Usage
Jinfo-opt PID, for example, to view maxpermsize of Java Process 3148:
Jinfo-flag maxpermsize 31483 and jmap print out all 'objects' in the memory of a Java Process (using the PID) (for example, the generated objects and their quantity) all objects in memory can be output.
You can even output heap in the VM in binary format. Method of use: jmap-histo PID if used in Shell jmap-histo
PID> A. log can save it to the text. After a period of time, use the text comparison tool to compare the jmap objects collected by GC.
-Dump: format = B, file = string 3024: the heap memory of the 3024 process can be output to the string file. For example, you can view the type and quantity of objects created in Java Process 3148. jmap-histo 3148
4,
Jstat

Extremely powerful VM memory monitoring tool. It can be used to monitor the size and memory usage of various heap and non-heap volumes in the VM memory. For example, check the GC status of process 3148. The jstat-GC 3148 parameter is described as follows: jstat-class PID: displays the number of loaded classes and the occupied space.
Jstat-compiler PID: displays information such as the number of real-time VM compilations.
Jstat-gc pid: displays GC information, the number of GC times, and the time. The last five items are the young GC count, young GC time, full GC count, full GC time, and total GC time.
Jstat

-Gccapacity: displays the usage and usage of three generations (young, old, and Perm) objects in VM memory. For example, pgcen displays the minimum perm memory usage.
Usage. pgcmx indicates the maximum memory usage of perm. PGC indicates the memory usage of the newly generated perm, while PC indicates the memory usage of the previous perm. Others can follow this analogy,
OC is the pure usage of old.
Jstat-gcnew PID: information of the new object.
Jstat-gcnewcapacity PID: information about the new object and its usage.
Jstat-gcold PID: information of the old object.
Jstat-gcoldcapacity PID: information about the old object and its usage.
Jstat-gcpermcapacity PID: information of the perm object and its usage.
Jstat-util PID: Statistics of GC information.
Jstat-printcompilation PID: information about the current VM execution.
In addition to the preceding parameter, you can add two numbers at the same time, for example, jstat-printcompilation 3024 250 6 is printed every 250 milliseconds, a total of 6 times, you can also add-H3 to display the title in each of the three rows.
5. jconsole6 and jvisualvm

Jvisualvm remote monitoring resource usage

  • Monitor another windows
    Add the following code to the file java. Policy (directory: C:/program files/Java/jdk1.6.0 _ 10/JRE/lib/security:
    Grant codebase "file: $ {java. Home}/../lib/tools. Jar "{
    Permission
    Java. Security. allpermission;
    };
    Run cmd: jstatd-J-Djava.security.policy = jstatd. All. Policy
  • Monitor another Linux
    Remote machine to start jstatd
    First, you need to prepare a java. Policy file to save/home/admin/jstatd. java. Policy
    Grant codebase "file: $ {java. Home}/../lib/tools. Jar "{
    Permission java. Security. allpermission;
    };
    Start jstatd
    Jstatd-J-Djava.security.policy =/home/admin/jstatd. java. Policy-J-Djava.rmi.server.logCalls = true

    At the same time, you need to execute a command (in Linux)
    Hostname-I
    If the display is 127.0.0.1, You need to modify the/etc/hosts file to remove the configuration of the local name, so that the local name is resolved to its IP address, such as 10.10.90.4
    To analyze the performance of an application running on JDK 6, you must disable class sharing of the application. Otherwise, the application may crash. To disable class sharing, use the-xshare: off parameter to start the application.

  • Use JMX monitoring
    In
    For example, add '-xshare: Off To java_opts of Tomcat's Catalina. Sh.
    -DCOM. Sun. Management. jmxremote-DCOM. Sun. Management. jmxremote. Port = 9004
    -DCOM. Sun. Management. jmxremote. Authenticate = false
    -DCOM. Sun. Management. jmxremote. SSL = false'

Sun official instructions:

Jvisualvm: http://java.sun.com/javase/6/docs/technotes/tools/share/jvisualvm.html

JPs: http://java.sun.com/javase/6/docs/technotes/tools/share/jps.html

Jstat: http://java.sun.com/javase/6/docs/technotes/tools/share/jstat.html

Jmap: http://java.sun.com/javase/6/docs/technotes/tools/share/jmap.html

Jconsole: http://java.sun.com/javase/6/docs/technotes/tools/share/jconsole.html

 


References: Http://newyearmsn.spaces.live.com/blog/cns! 8eb7b670d83848ec! 3429. Entry
Http://hi.baidu.com/qiaowz/blog/item/f08cac1ad3b96cfdae51337f.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.