Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Case Analysis of Java memory leak Monitoring tool and JVM Monitoring tool

2025-02-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Java memory leak monitoring tool and JVM monitoring tool example analysis, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Jstack-if the java program crashes to generate a core file, the jstack tool can be used to get information about the java stack and native stack of the core file, so you can easily know how the java program crashed and where the program went wrong. In addition, the jstack tool can be attached to a running java program to see the java stack and native stack information of the running java program at that time. If the running java program presents the state of hung, jstack is very useful. Currently, it is only available in JDK versions of Solaris and Linux.

Jconsole-jconsole is a real-time graphical monitoring tool based on Java Management Extensions (JMX). This tool uses JMX instructions built into JVM to provide real-time performance and resource monitoring, including Java program memory usage, Heap size, thread status, class allocation status, space usage and so on.

Jinfo-jinfo can know the configuration information of crashed Java applications from the core file, which is currently available only in JDK versions of Solaris and Linux.

Jmap-jmap can get specific memory matches from core files or processes, including Heap size, Perm size, and so on, which are currently available only in JDK versions of Solaris and Linux.

Jdb-jdb is used to debug core files and running Java processes in real time. It contains a wealth of commands to help you debug. Its function is very similar to dbx in Sun studio, but jdb is specifically designed for Java applications.

Jstat-jstat uses JVM built-in instructions for real-time command-line monitoring of Java application resources and performance, including monitoring Heap size and garbage collection status, and so on.

Jps-jps is used to check the specific status of all processes in the JVM, including process ID, process startup path, and so on.

Jstatd

Start the jvm monitoring service. It is a rmi-based application that provides information about native jvm applications to remote machines. The default port is 1099.

Example: jstatd-J-Djava.security.policy=my.policy

The my.policy file needs to be created by yourself, as shown below:

Grant codebase "file:$JAVA_HOME/lib/tools.jar" {permission java.security.AllPermission;}

This is a security policy file, because jdk does a jaas security check on jvm, so we have to set some policies so that jstatd is allowed to operate on the network.

The above operation failed and appeared:

Could not create remote object

Access denied (java.util.PropertyPermission java.rmi.server.ignoreSubClasses write)

Java.security.AccessControlException: access denied (java.util.PropertyPermission java.rmi.server.ignoreSubClasses write)

At java.security.AccessControlContext.checkPermission (AccessControlContext.java:323)

At java.security.AccessController.checkPermission (AccessController.java:546)

At java.lang.SecurityManager.checkPermission (SecurityManager.java:532)

At java.lang.System.setProperty (System.java:727)

At sun.tools.jstatd.Jstatd.main (Jstatd.java:122)

Create in your usr/java/bin the jstatd.all.policy file, with the content must be

Grant codebase "file:$ {java.home} /.. / lib/tools.jar" {permission java.security.AllPermission;}

JPS

List all jvm instances

Example:

Jps

List all jvm instances on this machine

Jps 192.168.0.77

List the jvm instances owned by the remote server 192.168.0.77, using the rmi protocol, and the default connection port is 1099 (provided that the remote server provides jstatd services)

The output is as follows:

Jones@jones:~/data/ebook/java/j2se/jdk_gc$ jps 6286 Jps 6174 Jstat

Jconsole

A graphical interface, you can observe the java process gc,class, memory and other information. Although intuitive, individuals prefer to use the jstat command (jstat is described in more detail in the final section).

Jinfo (unique under linux)

Observe the running environment parameters of the running java program: the parameters include the Java System property and the JVM command line parameters

Example: jinfo 2083

Where 2083 is the java process id number, which you can get with jps.

The output content is too much, do not list one by one here, you can try this command yourself.

Jstack (unique under linux)

You can observe the current operation and current state of all threads in the jvm.

Jstack 2083

The output is as follows:

Jmap (a unique and commonly used command under linux)

Observe the physical memory footprint of the running jvm.

The parameters are as follows:

-heap: the case of printing jvm heap

-histo: prints the histogram of the jvm heap. The output information includes the class name, the number of objects, and the size of the object occupation.

-histo:live: same as above, but only allowed for the surviving object

-permstat: print the permanent generation heap situation

The command uses:

Jmap-heap 2083

The memory usage of New Generation (Eden Space,From Space,To Space) and tenured generation,Perm Generation can be observed.

Output:

Jmap-histo 2083 | jmap-histo:live 2083

You can observe the situation of all objects in heap (all living objects in heap). Including the number of objects and the amount of space occupied.

Output:

Writing a script can quickly find the objects that take up the largest amount of heap, which is particularly effective in dealing with memory leaks.

Jstat

Finally, I would like to focus on this command.

This is an important and practical command in the jdk command, and you can observe the information related to classloader,compiler,gc.

The specific parameters are as follows:

-class: statistics of class loader behavior information

-compile: statistics of compilation behavior information

-gc: heap information when counting jdk gc

-gccapacity: statistics on the corresponding heap capacity of different generations (I don't know how to translate it well, including newborn area, senile area, permanent area)

-gccause: statistics of gc, (same as-gcutil) and events that cause gc

-gcnew: when counting gc, the situation of the new generation

-gcnewcapacity: when counting gc, the capacity of the new generation heap

-gcold: when counting gc, the situation in the elderly area

-gcoldcapacity: when counting gc, the heap capacity of the elderly area

-gcpermcapacity: when counting gc, the heap capacity of permanent area

-gcutil: when counting gc, heap

-printcompilation: I don't know what to do. I've never used it.

The commonly used parameters are:

Jstat-class 2083 1000 10 (monitoring every 1 second for a total of 10 times)

The meaning of the output is as follows:

LoadedNumber of classes loaded.BytesNumber of Kbytes loaded.UnloadedNumber of classes unloaded.BytesNumber of Kbytes unloaded.TimeTime spent performing class load and unload operations.

Jstat-gc 2083 2000 20 (monitoring every 2 seconds for a total of 10)

The meaning of the output is as follows:

S0CCurrent survivor space 0 capacity (KB). ECCurrent eden space capacity (KB). EUEden space utilization (KB). OCCurrent old space capacity (KB). OUOld space utilization (KB). PCCurrent permanent space capacity (KB). PUPermanent space utilization (KB). YGCNumber of young generation GC Events.YGCTYoung generation garbage collection time.FGCNumber of full GC events.FGCTFull garbage collection time.GCTTotal garbage collection time.

Output:

If you can use these commands skillfully, especially under linux, then you can replace monitoring tools such as jprofile, who will charge for it? He he.

The advantage of using commands is that they are fast and can assist with other commands, such as grep gawk sed, to assemble a variety of tools that meet your needs.

The usage of jps

It is used to view the specific status of all processes in JVM, including process ID, process startup path, and so on. Similar to ps on unix, it is used to display local java processes. You can see how many java programs are running locally and display their process numbers.

[root@localhost ~] # jps

25517 Jps

25444 Bootstrap

The usage of jstack

If the java program crashes to generate a core file, the jstack tool can be used to get information about the java stack and native stack of the core file, so that you can easily know how the java program crashed and where the program went wrong. In addition, the jstack tool can be attached to a running java program to see the java stack and native stack information of the running java program at that time. If the running java program presents the state of hung, jstack is very useful. Currently, it is only available in JDK versions of Solaris and Linux.

[root@localhost bin] # jstack 25444

Attaching to process ID 25917, please wait...

Debugger attached successfully.

Client compiler detected.

JVM version is 1.5.0_08-b03

Thread 25964: (state = BLOCKED)

Error occurred during stack walking:

Sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: get_thread_regs failed for a lwp

At sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$LinuxDebuggerLocalWorkerThread.execute (LinuxDebuggerLocal.java:134)

At sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.getThreadIntegerRegisterSet (LinuxDebuggerLocal.java:437)

At sun.jvm.hotspot.debugger.linux.LinuxThread.getContext (LinuxThread.java:48)

At

The usage of jstat

To determine if there is a memory problem with JVM? How to determine whether JVM garbage collection is normal? General top instructions basically can not meet such requirements, because it mainly monitors the overall system resources, it is difficult to locate java applications.

Jstat is a lightweight gadget that comes with JDK. The full name is "Java Virtual Machine statistics monitoring tool", which is located in the bin directory of java. It mainly uses the built-in instructions of JVM to monitor the resources and performance of Java applications in real time, including the monitoring of Heap size and garbage collection. It can be seen that Jstat is a lightweight tool specifically for JVM, which is very suitable. Due to the large JVM memory setting, the percentage change in the figure is not obvious.

A powerful tool for monitoring VM memory. Can be used to monitor the various heap and non-heap sizes in VM memory and their memory usage.

The jstat tool is particularly powerful with many options to take a closer look at the usage of various parts of the heap, as well as the number of loaded classes. When using it, you need to add the process id of the viewing process, and the selected parameters.

Grammatical structure:

Usage: jstat-help |-options

Jstat-[- t] [- h] [[]]

Parameter explanation:

Options-option. We usually use-gcutil to check gc.

The process number of vmid-VM, that is, the java process number that is currently running

Interval- interval (in seconds or milliseconds)

Count-number of times to print, or countless times by default

Percentage of space used in Survivor space 0 zone on S0-Heap

Percentage of space used in Survivor space 1 zone on S1-Heap

Percentage of space used in the Eden space area on E-Heap

Percentage of space used in the Old space area on O-Heap

Percentage of space used in P-Perm space area

YGC-the number of times Young GC occurred since the application was started and sampled

Time spent by YGCT- from application startup to sampling Young GC (in seconds)

FGC-the number of times Full GC occurred since the application was started and sampled

Time spent by FGCT- from application startup to sampling Full GC (in seconds)

GCT-Total time spent on garbage collection from application startup to sampling (in seconds)

The instance uses 1:

[root@localhost bin] # jstat-gcutil 25444

S0 S1 E O P YGC YGCT FGC FGCT GCT

11.63 0.00 56.46 66.92 98.49 162 0.248 6 0.331 0.579

The instance uses 2:

[root@localhost bin] # jstat-gcutil 25444 1000 5

S0 S1 E O P YGC YGCT FGC FGCT GCT

73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583

73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583

73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583

73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583

73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583

We can see that after 5 times of young gc, junk memory is put from Eden space area (E) into Old space area (O), causing a percentage change, resulting in the percentage of Survivor space usage reduced from 73.54% (S0) to 0% (S1). Effectively frees up memory space. In the green box, we can see that after a full gc, the memory in the Old space area (O) is reclaimed, from 99.05% to 67.52%.

The total number of times and total time consuming of young gc and full gc are printed at the same time in the figure. On the other hand, the time consumed by each young gc can be obtained by subtracting two lines of YGCT at intervals. The time consumed by each full gc can be subtracted by two lines of FGCT separated by each other. For example, a young gc occurs between the first and second lines indicated in the red box, and the time consumed is 0-0.252 = 0.252 seconds.

The utilization rate of resident memory area (P) always stays at about 98.49%, indicating that there is no sudden change in resident memory, which is relatively normal.

If young gc and full gc can occur normally, and both can effectively reclaim memory, and the change in the resident memory area is not obvious, it means that java memory release is normal, garbage collection is timely, and the probability of java memory leakage will be greatly reduced. But that doesn't mean there are no memory leaks.

GCT is the sum of time for YGCT and FGCT.

The above describes the ability of Jstat to view gc as a percentage. In fact, it also has functions, such as loading class information statistics function, memory pool information statistics function and so on, which are printed in the form of absolute values and are rarely used, so I will not introduce them here.

[root@localhost bin] # ps-ef | grep java

Root 25917 1 2 23:23 pts / 2 00:00:05 / usr/local/jdk1.5/bin/java-Djava.endorsed.dirs=/usr/local/jakarta-tomcat-5.0.30/common/endorsed-classpath / usr/local/jdk1.5/lib/tools.jar:/usr/local/jakarta-tomcat-5.0.30/bin/bootstrap.jar:/usr/local/jakarta-tomcat-5.0.30/bin/commons-logging-api.jar-Dcatalina.base=/usr/ Local/jakarta-tomcat-5.0.30-Dcatalina.home=/usr/local/jakarta-tomcat-5.0.30-Djava.io.tmpdir=/usr/local/jakarta-tomcat-5.0.30/temp org.apache.catalina.startup.Bootstrap start

Jstat-class pid: displays information such as the number of loaded class and the space occupied.

The instance uses 3:

[root@localhost bin] # jstat-class 25917

Loaded Bytes Unloaded Bytes Time

2629 2916.8 29 24.6 0.90

Jstat-compiler pid: displays information such as the number of VM real-time compilations.

The instance uses 4:

[root@localhost bin] # jstat-compiler 25917

Compiled Failed Invalid Time FailedType FailedMethod

768 0 0 0.70 0

Jstat-gccapacity: you can show the usage and usage of young,old,perm objects in VM memory. For example, PGCMN shows the minimum perm memory usage, PGCMX shows the maximum memory usage of perm, PGC is the current newly generated perm memory usage, and PC is the previous perm memory usage. According to this analogy, OC is the pure occupancy in old.

[root@localhost bin] # jstat-gccapacity 25917

NGCMN 640.0

NGCMX 4992.0

NGC 832.0

S0C 64.0

S1C 64.0

EC 704.0

OGCMN 1408.0

OGCMX 60544.0

OGC 9504.0

OC 9504.0 OC is the pure usage in old.

PGCMN 8192.0 PGCMN shows the minimum perm memory usage

PGCMX 65536.0 PGCMX shows the maximum memory usage of perm

PGC 12800.0 PGC is the current newly generated perm memory footprint

PC 12800.0 PC is a pre-perm memory usage

YGC 164

FGC 6

Jstat-gcnew pid: information about the new object

[root@localhost bin] # jstat-gcnew 25917

S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT

64.0 64.0 47.4 0.0 2 15 32.0 704.0 145.7 168 0.254

Jstat-gcnewcapacity pid: information about new objects and their occupancy

[root@localhost bin] # jstat-gcnewcapacity 25917

NGCMN NGCMX NGC S0CMX S0C S1CMX S1C ECMX EC YGC FGC

640.0 4992.0 832.0 64.0 448.0 448.0 64.0 4096.0 704.0 168 6

Jstat-gcold pid: information about the old object.

[root@localhost bin] # jstat-gcold 25917

PC PU OC OU YGC FGC FGCT GCT

12800.0 12617.6 9504.0 6561.3 169 6 0.335 0.591

Information about the jstat-gcoldcapacity pid:old object and its usage.

[root@localhost bin] # jstat-gcoldcapacity 25917

OGCMN OGCMX OGC OC YGC FGC FGCT GCT

1408.0 60544.0 9504.0 9504.0 169 6 0.335 0.591

Jstat-gcpermcapacity pid: information about the perm object and its usage.

[root@localhost bin] # jstat-gcpermcapacity 25917

PGCMN PGCMX PGC PC YGC FGC FGCT GCT

8192.0 65536.0 12800.0 12800.0 169 6 0.335 0.591

Jstat-printcompilation pid: the information currently executed by VM.

[root@localhost bin] # jstat-printcompilation-h4 25917 1000 5

Print every 1000 milliseconds for a total of five times, and you can add-h4 to display the title every three lines.

Compiled Size Type Method

788 73 1 java/io/File

788 73 1 java/io/File

788 73 1 java/io/File

Compiled Size Type Method

788 73 1 java/io/File

788 73 1 java/io/File

The usage of jmap

Print out all the 'objects' in the memory of a java process (using pid) (e.g. those objects are generated and their number).

A tool that can output all objects in memory, and even output heap in VM into text in binary. Use the method jmap-histo pid. If you use SHELL jmap-histo pid > a.log to save it to text, after a while, using the text comparison tool, you can compare which objects have been recycled by GC. Jmap-dump:format=b,file=String 3024 can output the memory heap of 3024 processes to a String file.

[root@localhost bin] # jmap-histo 25917

Attaching to process ID 26221, please wait...

Debugger attached successfully.

Client compiler detected.

JVM version is 1.5.0_08-b03

Iterating over heap. This may take a while...

Unknown oop at 0xaa6e42d0

Oop's klass is null

Object Histogram:

Size Count Class description

3722768 30467 * ConstMethodKlass

1976480 25334 char []

1907880 46994 * SymbolKlass

1762088 2947 byte []

1709536 30467 * MethodKlass

1487816 2600 * ConstantPoolKlass

1009576 2600 * InstanceKlassKlass

904880 2199 * ConstantPoolCacheKlass

741432 30893 java.lang.String

653576 4785 int []

351760 4397 java.lang.reflect.Method

277824 2894 java.lang.Class

248704 3401 short []

200888 4411 java.lang.Object []

193656 4045 java.lang.Object []

179744 5617 java.util.TreeMap$Entry

175688 1800 java.util.HashMap$Entry []

165288 6887 java.util.HashMap$Entry

104736 3273 java.lang.ref.SoftReference

104136 4339 java.lang.ref.WeakReference

96096 3521 java.lang.String []

86160 3590 java.util.Hashtable$Entry

85584 3566 java.util.ArrayList

83472 1206 java.util.Hashtable$Entry []

82944 1728 java.beans.MethodDescriptor

80560 265 * ObjArrayKlassKlass

69120 1728 java.util.HashMap

52464 3055 java.lang.Class []

43040 1076 java.util.Hashtable

42496 664 org.apache.commons.modeler.AttributeInfo

37880 947 java.util.TreeMap

33896 557 javax.management.modelmbean.ModelMBeanAttributeInfo []

33152 518 java.beans.PropertyDescriptor

616 11 org.springframework.aop.framework.ProxyFactory

608 19 java.util.PropertyPermission

608 38 org.springframework.beans.MutablePropertyValues

608 38 org.springframework.beans.factory.support.MethodOverrides

608 2 * ArrayKlassKlass

608 38 org.springframework.beans.factory.config.ConstructorArgumentValues

608 4 org.apache.xerces.impl.XMLDTDScannerImpl

576 24 java.util.Stack

576 36 java.util.regex.Pattern$Category

576 24 org.apache.naming.NamingEntry

560 7 java.net.URL []

552 23 sun.management.MappedMXBeanType$BasicMXBeanType

552 1 java.util.Locale []

552 22 java.io.ObjectStreamField []

544 17 java.util.Collections$SynchronizedMap

176 11 java.util.regex.Pattern$Ctype

8 1 sun.reflect.GeneratedMethodAccessor49

8 1 sun.reflect.GeneratedMethodAccessor6

8 1 sun.reflect.GeneratedConstructorAccessor10

Heap traversal took 12.003 seconds.

The usage of jinfo

You can output and modify the opts of the runtime java process. The use is relatively simple, that is, it can output and modify the running parameters of the java process at runtime. The usage is jinfo-opt pid, such as: to view the MaxPerm size of 2788, you can use jinfo-flag MaxPermSize 2788.

The usage of jconsole

Jconsole: a java GUI monitoring tool that can display a variety of data in a graphical form. And you can monitor the remote server VM through a remote connection.

Use java to write GUI procedures, used to monitor VM, and can monitor remote VM, very easy to use, and very powerful. Type jconsole on the command line and select the process.

But I didn't run it. I always reported the following mistakes. Yes, my friend, take a look at it.

[root@localhost bin] # jconsole

Exception in thread "AWT-EventQueue-0" java.awt.HeadlessException:

No X11 DISPLAY variable was set, but this program performed an operation which requires it. At java.awt.GraphicsEnvironment.checkHeadless (GraphicsEnvironment.java:159)

At java.awt.Window. (Window.java:317)

At java.awt.Frame. (Frame.java:419)

At javax.swing.JFrame. (JFrame.java:194)

At sun.tools.jconsole.JConsole. (JConsole.java:65)

At sun.tools.jconsole.JConsole$4.run (JConsole.java:666)

At java.awt.event.InvocationEvent.dispatch (InvocationEvent.java:209)

At java.awt.EventQueue.dispatchEvent (EventQueue.java:461)

At java.awt.EventDispatchThread.pumpOneEventForHierarchy (EventDispatchThread.java:242)

At java.awt.EventDispatchThread.pumpEventsForHierarchy (EventDispatchThread.java:163)

At java.awt.EventDispatchThread.pumpEvents (EventDispatchThread.java:157)

At java.awt.EventDispatchThread.pumpEvents (EventDispatchThread.java:149)

At java.awt.EventDispatchThread.run (EventDispatchThread.java:110)

The usage of jdb

Used to debug core files and running Java processes in real time, it contains a wealth of commands to help you debug, its function is very similar to dbx in Sun studio, but jdb is specifically used for Java applications.

The usage of jmap

Print out all the 'objects' in the memory of a java process (using pid) (e.g. those objects are generated and their number).

A tool that can output all objects in memory, and even output heap in VM into text in binary. Use the method jmap-histo pid. If you use SHELL jmap-histo pid > a.log to save it to text, after a while, using the text comparison tool, you can compare which objects have been recycled by GC. Jmap-dump:format=b,file=String 3024 can output the memory heap of 3024 processes to a String file.

[root@localhost bin] # jmap-histo 25917

Attaching to process ID 26221, please wait...

Debugger attached successfully.

Client compiler detected.

JVM version is 1.5.0_08-b03

Iterating over heap. This may take a while...

Unknown oop at 0xaa6e42d0

Oop's klass is null

Object Histogram:

Size Count Class description

3722768 30467 * ConstMethodKlass

1976480 25334 char []

1907880 46994 * SymbolKlass

1762088 2947 byte []

1709536 30467 * MethodKlass

1487816 2600 * ConstantPoolKlass

1009576 2600 * InstanceKlassKlass

904880 2199 * ConstantPoolCacheKlass

741432 30893 java.lang.String

653576 4785 int []

351760 4397 java.lang.reflect.Method

277824 2894 java.lang.Class

248704 3401 short []

200888 4411 java.lang.Object []

193656 4045 java.lang.Object []

179744 5617 java.util.TreeMap$Entry

175688 1800 java.util.HashMap$Entry []

165288 6887 java.util.HashMap$Entry

104736 3273 java.lang.ref.SoftReference

104136 4339 java.lang.ref.WeakReference

96096 3521 java.lang.String []

86160 3590 java.util.Hashtable$Entry

85584 3566 java.util.ArrayList

83472 1206 java.util.Hashtable$Entry []

82944 1728 java.beans.MethodDescriptor

80560 265 * ObjArrayKlassKlass

69120 1728 java.util.HashMap

52464 3055 java.lang.Class []

43040 1076 java.util.Hashtable

42496 664 org.apache.commons.modeler.AttributeInfo

37880 947 java.util.TreeMap

33896 557 javax.management.modelmbean.ModelMBeanAttributeInfo []

33152 518 java.beans.PropertyDescriptor

616 11 org.springframework.aop.framework.ProxyFactory

608 19 java.util.PropertyPermission

608 38 org.springframework.beans.MutablePropertyValues

608 38 org.springframework.beans.factory.support.MethodOverrides

608 2 * ArrayKlassKlass

608 38 org.springframework.beans.factory.config.ConstructorArgumentValues

608 4 org.apache.xerces.impl.XMLDTDScannerImpl

576 24 java.util.Stack

576 36 java.util.regex.Pattern$Category

576 24 org.apache.naming.NamingEntry

560 7 java.net.URL []

552 23 sun.management.MappedMXBeanType$BasicMXBeanType

552 1 java.util.Locale []

552 22 java.io.ObjectStreamField []

544 17 java.util.Collections$SynchronizedMap

176 11 java.util.regex.Pattern$Ctype

8 1 sun.reflect.GeneratedMethodAccessor49

8 1 sun.reflect.GeneratedMethodAccessor6

8 1 sun.reflect.GeneratedConstructorAccessor10

Heap traversal took 12.003 seconds.

The usage of jinfo

You can output and modify the opts of the runtime java process. The use is relatively simple, that is, it can output and modify the running parameters of the java process at runtime. The usage is jinfo-opt pid, such as: to view the MaxPerm size of 2788, you can use jinfo-flag MaxPermSize 2788.

The usage of jconsole

Jconsole: a java GUI monitoring tool that can display a variety of data in a graphical form. And you can monitor the remote server VM through a remote connection.

Use java to write GUI procedures, used to monitor VM, and can monitor remote VM, very easy to use, and very powerful. Type jconsole on the command line and select the process.

But I didn't run it. I always reported the following mistakes. Yes, my friend, take a look at it.

[root@localhost bin] # jconsole

Exception in thread "AWT-EventQueue-0" java.awt.HeadlessException:

No X11 DISPLAY variable was set, but this program performed an operation which requires it. At java.awt.GraphicsEnvironment.checkHeadless (GraphicsEnvironment.java:159)

At java.awt.Window. (Window.java:317)

At java.awt.Frame. (Frame.java:419)

At javax.swing.JFrame. (JFrame.java:194)

At sun.tools.jconsole.JConsole. (JConsole.java:65)

At sun.tools.jconsole.JConsole$4.run (JConsole.java:666)

At java.awt.event.InvocationEvent.dispatch (InvocationEvent.java:209)

At java.awt.EventQueue.dispatchEvent (EventQueue.java:461)

At java.awt.EventDispatchThread.pumpOneEventForHierarchy (EventDispatchThread.java:242)

At java.awt.EventDispatchThread.pumpEventsForHierarchy (EventDispatchThread.java:163)

At java.awt.EventDispatchThread.pumpEvents (EventDispatchThread.java:157)

At java.awt.EventDispatchThread.pumpEvents (EventDispatchThread.java:149)

At java.awt.EventDispatchThread.run (EventDispatchThread.java:110)

The usage of jdb

Used to debug core files and running Java processes in real time, it contains a wealth of commands to help you debug, its function is very similar to dbx in Sun studio, but jdb is specifically used for Java applications.

Original link: http://blog.csdn.net/jacky0922/article/details/6201878

This is the answer to the example analysis of Java memory leak monitoring tool and JVM monitoring tool. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report