Deep understanding of Java Virtual Machines (eight): Java Memory analysis tools-mat and OQL

Source: Internet
Author: User

The following content is translated from the mat help document.

Mat Download Address http://www.eclipse.org/mat/
One, Class histogram


Class histogram shows the classes found in the snapshot, the number of objects to each class, the heap memory consumption Of these objects, and the minimum retained size of the objects
Second, Dominator
tree


Dominator tree shows for a particular object which other objects depend on it and would be garbage collected if that partic Ular object becomes unreachable.
Iii. Paths to GC roots


This view is objects responsible for keeping the selected object in the heap.

Componenet A Heap dump contains many objects. But which of those belong to your component? And what conclusions can you draw from them? This is where the Component can help.
Four, OQL


OQL is the Build-in object query language. Learn to perform custom sql-like queries on the heap dump in one minute. Classes as tables, objects as rows, and fields as columns.

1, Oql-select

1.SELECT * from java.lang.String
2.SELECT toString (s), S.count, s.value from java.lang.String s
3.SELECT tostr ING (s) as value,s. @usedHeapSize as "shallow Size" from java.lang.String s
(@ is a property accessor, you can use as as an individual name )
4.SELECT as retained set * from Java.lang.String
(using as retained set to obtain a collection of objects associated with the selected object)
5.SELECT OBJECTS Dominators (s From java.lang.String s
( OBJECTS keyword makes dominators return two-dimensional array to a one-dimensional object list )
6.SELECT DISTINCT OBJECTS Classof (s) from java.lang.String s
( DISTINCT to repeat )
 
7, query for all exception objects
SELECT * from instanceof java.lang.Exception exceptions
Select exceptions. @displayName, Exceptions.detailMessage.toString () from instanceof java.lang.Exception exceptions 2, Oql-from

1.SELECT * from "java\.lang\. *"
(Support Regular)
2.SELECT * from java.lang.String
3.SELECT * from 0xe14a100
(Query based on class object 's address in the heap dump snapshot)
4.SELECT * from 3022
(based on the address ID of the object in the heap dump snapshot)
5.SELECT * FROM (SELECT * from Java.lang.Class C)
6.SELECT * from ${snapshot}.getclasses ()
(using property accessors)
7.SELECT * from instanceof java.lang.ref.Reference
(instanceof will also query subclasses of the specified class.)
8.SELECT * from OBJECTS java.lang.String
(OBJECTS prohibits oql to interpret the scope of the query as an object instance, the result is java.lang.String corresponding class)

3, Oql-where
1.SELECT * from java.lang.String s WHERE s.count >= 100
2.SELECT * from java.lang.String s WHERE toString (s) like ". *day"
3.SELECT * from java.lang.String s WHERE s.value not in Dominators (s)
4.SELECT * from java.lang.String s WHERE toString (s) = "Monday"
5.SELECT * from java.lang.String s WHERE s.count > S. @retainedHeapSize > S. @usedHeapSize
6.SELECT * from java.lang.String s WHERE s.count > 1000 OR s.value. @length >1000
7.SELECT * from java.lang.String s WHERE (s.count > 1000) = True
WHERE toString (s) = "Monday"
WHERE Dominators (s). Size () = 0
WHERE s.retainedheapsize > 1024L
WHERE S. @GCRootInfo!= null
4. Property accessors

1.[<alias>.] <field>.<field> .....

(Accessing the fields of the object in the heap dump snapshot)

2.[<alias>.] @<attribute> .....

(Accessing Java Bean properties)

Goal Interface Property Meaning
An object in any heap Iobject ObjectId ID of the object in the snapshot
Objectaddress The address of the object in the snapshot
Class class to which the object belongs
Usedheapsize Shallowsize of objects
Retainedheapsize Retainedsize of objects
DisplayName The display name of the object
Class object Iclass Classloaderid Class Loader ID
Any array IArray Length The length of the array


5. OQL built-in function

. [<alias>] @< method > ([< expression >,< expression) .....

(Invoking the Oql Java method, plus "()" will cause mat to be interpreted as a OQL Java call)


Common OQL Java methods

Goal Interface Property Meaning
$snapshot Isnapshot Getclasses () Get a collection of all classes
Getclassesbyname (String Name,boolean includesubclasses) Gets the collection of the specified class
Class Object Iclass Hassuperclass () Returns True if the object has a parent class
Isarraytype () Returns true if class is an array type

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.