OQL query syntax of jhat tool

 

jmap -dump:format=b,file=./abc.dump

After that, the abc.dump file will be generated, and if the service and its performance are quite good, you can run the command directly on the server:

jhat -J-Xmx2000M abc.dump 

After running, the default port 7000 will be opened to provide http services to the outside world, and you can view it with a browser.

 

From:http://blog.csdn.net/wanglha/article/details/40181767

OQL (Object Query Language) in jhat 
If you need to filter or query the objects of the heap according to certain conditions, it is possible to execute OQL in the html page of jhat to query the objects that meet the conditions.

Basic syntax: 
select < JavaScript  expression to select>
[from [instanceof] <class name> <identifier>]
[where <javascript boolean expression to filter>]

Explanation: 
(1) class name is the fully qualified name of a Java class, such as: java.lang.String, java.util.ArrayList, [C is a char array, [Ljava.io.File is java.io.File[]
(2) The fully qualified name of the class is not enough to uniquely identify a class, because different ClassLoaders load the same They are of different types in the jvm
(3) instanceof means to also query the subclass of a certain class, if the instanceof is not clear, only the class specified by the class name will be precisely queried
(4) both from and where clauses are available Selected
(5) java field representation: obj.field_name; java array representation: array[index]

Example: 
(1) Query strings with length greater than 100
select s from java.lang.String s where s.count > 100

(2) Query an array with a length greater than 256
select a from [I a where a.length > 256
(3) Display a string matching a regular expression
select a.value.toString() from java.lang.String s where /java/(s.value.toString())
(4) Display the file paths of all file objects
select file.path.value.toString() from java.io.File file
(5) Display the class names of all ClassLoaders
select classof (cl).name from instanceof java.lang.ClassLoader cl
(6) query object by reference
select o from instanceof 0xd404d404 o

built-in object -- heap 
(1) heap.findClass(class name) -- find class
select heap. findClass("java.lang.String").superclass
(2)heap.findObject(object id) -- find the object
select heap.findObject("0xd404d404")
(3)heap.classes -- enumeration of all classes
select heap .classes
(4)heap.objects -- enumeration of all objects
select heap.objects("java.lang.String")
(5) heap.finalizables -- enumeration of java objects waiting for garbage collection
(6) heap.livepaths -- the survival path of an object
select heaplivepaths(s) from java .lang.String s
(7)heap.roots -- the enumeration of the heap root set

identifies the function of the object 
(1)classof(class name) -- the class object that returns the java object
select classof(cl).name from instanceof java. lang.ClassLoader cl
(2)identical(object1,object2) -- returns whether two objects are the same instance
select identical(heap.findClass("java.lang.String").name, heap.findClass("java.lang .String").name)
(3)objectid(object) -- returns the id of the object
select objectid(s) from java.lang.String s
(4)reachables -- returns the objects reachable from the object
select reachables(p ) from java.util.Properties p -- query the objects reachable from the Properties object
select reachables(u, "java .NET.URL.handler") from java .Net .URL u -- Query the objects reachable from the URL object, but not including the objects reachable from URL.handler
(5) referrers(object) -- Returns a reference to an object Object
select referrers(s) from java.lang.String s where s.count > 100
(6)referees(object) -- Returns the object referenced by an object
select referees(s) from java.lang.String s where s. count > 100
(7)refers(object1,object2) -- Returns whether the first object refers to the second object
select refers(heap.findObject("0xd4d4d4d4"),heap.findObject("0xe4e4e4e4"))
(8)root (object) -- returns whether the object is a member of the root set
select root(heap.findObject("0xd4d4d4d4")) 
(9) sizeof(object) -- returns the size of the object
select sizeof(o) from [I o
(10) toHtml(object) -- returns the html format of the object
select "<b>" + toHtml(o) + "</b>" from java.lang.Object o
(11) select multiple values
select {name:t.name?t.name.toString():"null",thread:t} from instanceof java.lang.Thread t

array, iterator and other functions 
(1)concat(enumeration1,enumeration2) -- will Array or enumeration for connection
select concat(referrers(p),referrers(p)) from java.util.Properties p
(2)contains(array, expression) -- Whether the elements in the array satisfy an expression
select p from java. util.Properties where contains(referres(p), "classof(it).name == 'java.lang.Class'")
returns the java.util.Properties object referenced by java.lang.Class
built-in variable
it - - the current iteration element
index -- the index of the current iteration element
array -- the iterated array
(3) count(array, expression) -- the number of elements that satisfy a certain condition
select count(heap.classes(), "/ java.io./(it.name)")
(4)filter(array, expression) -- filter out elements that satisfy a certain condition
select filter(heap.classes(), "/java.io./(it.name)")
(5)length(array) -- Return the length of the array
select length(heap.classes())
(6)map(array,expression) -- Convert the elements in the array according to the expression map
select map(heap.classes( ),"index + '-->' + toHtml(it)")
(7)max(array,expression) -- maximum value, min(array,expression)
select max(heap.objects("java.lang.String "),"lhs.count>rhs.count")
built-in variable
lhs -- left element
rhs -- right element
(8)sort(array,expression)
--sort select sort(heap.objects('[C' ),'sizeof(lhs)-sizeof(rhs)')
(9)sum(array,expression) -- sum
select sum(heap.objects('[C'),'sizeof(it)')
(10) toArray(array) -- return an array
(11) unique(array) -- unique array

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326296314&siteId=291194637