Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Java memory analysis tool uses detailed MAT     - jQuery plugin dynamic label generation (Linux)

- Linux foundation tutorial: how to modify the host name on CentOS or RHEL 7 (Linux)

- Set up MySQL master and slave servers under Ubuntu 14.04 (Server)

- CentOS 6.5 installation and configuration Cobbler (Server)

- Introduction Linux namespace (Linux)

- Linux mount command Detailed (Linux)

- Preps - Print within the specified range of IP addresses (Linux)

- Java application server WildFly (Server)

- CentOS 6.5 install VNC-Server (Linux)

- Compile and install Redis and register as a system service under RedHat5.8 environment (Database)

- Commentary Apache + Tomcat + JK implement Tomcat clustering and load (Server)

- MNIST presentation and database conversion (Database)

- How to choose the first programming language based on the life you want (Programming)

- Summary of Docker mounted directory (Server)

- CentOS yum source configuration (Linux)

- C language programming entry - Common operators (Programming)

- ssh port forwarding Comments (Server)

- Dialogue UNIX:! $ # @ *% (Linux)

- How to protect your eyes automatically adjust the screen brightness on Linux (Linux)

- Linux Task Scheduler (at, crontab) (Linux)

 
         
  Java memory analysis tool uses detailed MAT
     
  Add Date : 2017-08-31      
         
         
         
  This is a read MAT helper notes. Heap dump java process is a memory snapshot at a particular time. Usually before triggering heap dump will conduct a full gc, so dump out the contents of the object contains gc after.

dump file that contains the contents:

1, all of the objects: classes, fields, native value and reference;

2, all of the categories: classloader, class name, superclass, static fields;

3, GC root: can touch up objects defined JVM;

4, the thread stack and local variables: the thread call stack, local objects per frame information.

dump file does not contain information about memory allocation, and therefore can not be queried who created the object which such information.

Shallow heap is a memory space occupied by the object, an object needs 32 or 64bits.

Retained set of X is X after being recovered jvm gc remove a group object.

Retained heap of X is in the retained set of shallow heap size X all objects and. In other words, to keep alive X memory space required.

Popular speaking, shallow heap is a real space objects in memory, and retained heap after an object has been released from the recovery gc memory space.


Dominator tree: define an object x dominate the object y, when the path from the root to the beginning of each of the y have been x. White said that as long as the surviving object y, then there must be a x object. Dominator tree is a reference to an object graph into a tree structure. Kept alive to help find dependencies between objects, but also to identify the biggest chunk retained memory. Immediate dominator x of y y is from recent dominator.

Dominator tree has several attributes:

1, the object (object sets x dominate) object x subtree included representatives of the retained set x;

2, if the immediate dominator x is y, then x is immediate dominator also dominate y, and so on;

3, dominate tree in the side of the object reference does not mean that the corresponding edge Ituri, not strictly a direct object references.

Gc root: root is a gc an object, the object can be accessed from outside the heap read. Here are some ways to make an object become gc roots.

1, System class: Bootstrap or system is class loader classes, such rt.jar in the java.util *;.

2, JNI local: native code for local variables, such as JNI code is user-defined and JVM internal code;

3, JNI global: native code of the global variables;

4, Thread block: Active objects referenced in the current thread block;

5, Thread: has started and there is no stop thread;

6, busy monitor: is called the wait () or notify () or object is synchronized synchronized synchronized method if it is, then the static method refers to the class of non-static method refers to the object;

7, java local: local variables, such as variables and methods within the reference methods created;

8, native stack: native code's access parameters, such as file / net / IO methods and parameters reflected;

9, finalizable: in a queue waiting for its object finalizer run;

10, unfinalized: an object with finalize methods have not yet been finalize, but also did not enter the finalizer queue waiting finalize;

11, unreachable: not to touch objects in the MAT is marked as root to retain object, otherwise it will not appear in the analysis;

12, java stack frame: java stack frame contains the local variables, when the dump is parsed and the preferences set in over the stack frames as objects, then will produce;

13, unknown: the location of the root type.

Next is some access dump method:

1, when the oom dump: JVM parameters: -XX: + HeapDumpOnOutOfMemoryError

2, interactive environment dump:

1) JVM parameters: -XX: + HeapDumpOnCtrlBreak

2) external tools: jmap -dump: format = b, file = < filename.hprof>

3) external tools: jconsole

4) with external tools: MAT

5) kill -3 < pid>

6) jstack -l < pid> < dumpfile>

Some troubleshooting tips:

1. Find a large object through the top consumers, can be carried out in accordance with the group by class, classloader and package;

2. Find an object by immediate dominator responsibility for a group of objects to quickly locate useful holders, this operation is a direct solution to the "Who these objects alive" problem, rather than "a reference to those who object," the problem, more direct and efficient;

3, run classloader analysis highlights the importance of this is reflected in: First, the application uses a different classloader load the class, second class different classloader loaded permanently stored in different generations, which theoretically also can be recycled. When a class is loaded at a different classloader, this time to determine the quantity of each instance loader at loader which is more important, in order to take out another recovery;

4, analysis of the thread itself heap dump contains the thread information, you can view the threads of overview and detail through MAT, detail in the thread heap memory information, but also the thread stack, and also includes a local operating system stack. Suppose not heap dump, we checked into the system has a problem, how to troubleshoot the thread angle it? First top -H -p < pid> in the thread pattern to check the running java applications, find occupied cpu or memory big thread, logging thread id, then printf% x < tid> converted to hexadecimal, then jstack -l < pid> thread.log the thread java process dump out and find tid from the inside, which thread analysis is taking up system resources.

5, analysis of java class container, because the container class java is most commonly used to store objects, so the memory leak occurs theoretical risk is highest. From several perspective: 1) array filling rate inquiry (fill rate fill ratio is the ratio of non-null elements in the array) print array of non-native type filling rate of frequency distribution, thereby investigation array system utilization; 2 ) in accordance with the array size grouping query, print a histogram grouped according to size; 3) collection of fill rate inquiry, ArrayList / HashMap / Hashtable / Properties / Vector / WeakHashMap / ConcurrentHashMap $ Segment; 4) collection grouped according to size histogram; 5 ) See a list of all the objects inside; 6) View hashmap in all objects; 7) in view hashset objects; 8) check the map of collision rate; 9) check all only a constant array.

6, analysis Finalizer, 1) query objects finalizer being processed; 2) Discover finalizer prepared to handle objects; 3) direct view finalizer thread; 4) View thread local objects finalizer thread.
     
         
         
         
  More:      
 
- Nagios (centreon) monitoring LVS (Server)
- High-performance JavaScript reflows and repaints (Programming)
- Linux find command to find files (Linux)
- Go powerful development server simple example (Server)
- WordPress blog installation Redis Cache (Server)
- To compile install and test Swift under Linux (Linux)
- Linux cut Command Study Notes (Linux)
- Subsequent binary search tree traversal sequence (Programming)
- Linux installation beautify early experience (Linux)
- MySQL my.cnf sql_mode schema modifications (Database)
- Safety testing Unix and Linux server entry succinctly (Linux)
- How to cool down your Ubuntu system (Linux)
- Use GLOBK batch command network adjustment (Linux)
- Quickly build and install Linux KVM system (Linux)
- Linux System Administrator common interview questions and answers 30 (Linux)
- Using 30 seconds to write a detailed analysis of garbage removal system (Linux)
- By creating a personal technology blog Detailed GitHub (Linux)
- RedHat Linux 6 desktop installation (Linux)
- Some of the bibliographic management tools to good use on linux (Linux)
- Basic Java JNI (Programming)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.