Created
February 17, 2016 02:59
-
-
Save ytoshima/dbaf6df782037a29feaf to your computer and use it in GitHub Desktop.
OQL samples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//----------------- class looader and loaded classes | |
select map(heap.objects('java.lang.ClassLoader'), function (it) { | |
var res = ''; | |
res += "<br/>ClassLoader " + toHtml(it) + "<br/>"; | |
res += listLoadedClasses(it); | |
return res + "<br>"; | |
function listLoadedClasses(cl) { | |
var res = ""; | |
if (cl.classes != null) { | |
if (cl.classes.elementData != null) { | |
var classes = toArray(cl.classes.elementData); | |
for (var i = 0; i < classes.length; i++) { | |
if (classes[i] != null) { | |
res += " " + toHtml(classes[i]) + " instance count: " + | |
count(heap.objects(classes[i])) + "<br/>"; | |
} | |
} | |
} | |
} | |
return res; | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select map(heap.objects('org.apache.xerces.dom.DeferredDocumentImpl'), function(it) { | |
function contains(a, obj) { | |
var i = a.length; | |
while (i--) { | |
if (a[i] == obj) { | |
return true; | |
} | |
} | |
return false; | |
} | |
function containsid(a, obj) { | |
var i = a.length; | |
while (i--) { | |
if (objectid(a[i]) == objectid(obj)) { | |
return true; | |
} | |
} | |
return false; | |
} | |
function descNodeListCache(nl) { | |
var t = '<div style="border: 1px dashed grey; margin: 4px;">'; | |
t += toHtml(nl); | |
t += '<br/>fChild: ' + toHtml(nl.fChild); | |
t += '<br/>fChildIndex: ' + nl.fChildIndex; | |
t += '<br/>fLength: ' + nl.fLength; | |
t += '<br/>next: ' + toHtml(nl.next); | |
if (nl.fChildIndex >= 0) t += '<br/>Active NodeListCache'; | |
return t + '</div>\n'; | |
} | |
function getFChildInNodeListCache(nl) { | |
if (nl == null) return null; | |
return nl.fChild; | |
} | |
function getFLengthInNodeListCache(nl) { | |
if (nl == null) return -2; | |
return nl.fLength; | |
} | |
function descNode(node) { | |
var t = '<div style="border: 1px dashed grey; margin: 4px;">'; | |
if (node != null) { | |
t += toHtml(node); | |
if (node.localName != null) { | |
t += "<br/>localName: " + node.localName.value.toString(); | |
} | |
if (node.name != null) { | |
t += "<br/>name: " + node.name.value.toString(); | |
} | |
t += '<br/>nextSibling: ' + toHtml(node.nextSibling); | |
t += '<br/>previousSibling: ' + toHtml(node.previousSibling); | |
var fChildInCache = null; | |
var fLengthInCache = -3; | |
if (classof(node).isSubclassOf(heap.findClass("org.apache.xerces.dom.ParentNode"))) { | |
t += "<br/>fNodeListCache: "; | |
if (node.fNodeListCache != null) { | |
t += descNodeListCache(node.fNodeListCache); | |
fChildInCache = getFChildInNodeListCache(node.fNodeListCache); | |
fLengthInCache = getFLengthInNodeListCache(node.fNodeListCache); | |
} else { | |
t += "(null)"; | |
} | |
} | |
t += "<br/>firstChild: " + toHtml(node.firstChild); | |
var children = new Array(); | |
if (node.firstChild != null) { | |
var child = node.firstChild; | |
while (child != null) { | |
children.push(child); | |
t += descNode(child); | |
child = child.nextSibling; | |
} | |
} | |
if (fChildInCache != null) { | |
if (containsid(children, fChildInCache) == false) { | |
t += "<br/>ERROR: fChild " + toHtml(fChildInCache) + | |
" is not on the firstChild list of " + toHtml(node) + | |
" ownerDoc: " + toHtml(node.ownerDocument); | |
t += "<br/>Cache fLength = " + fLengthInCache; | |
t += "<br/> nodes len = " + children.length + " nodes are: "; | |
for (i = 0; i < children.length; i++) { | |
t += "<br/>" + toHtml(children[i]); | |
} | |
} | |
} | |
} | |
return t + '</div>\n'; | |
} | |
var res = '<div style="font-family: Menlo, Courier, monospace; font-size: small;">'; | |
res += toHtml(it); | |
res += '<br/>fDocumentURI: ' ; | |
if (it.fDocumentURI == null) res += '(null)'; | |
else res += it.fDocumentURI.value.toString(); | |
res += ' <br/>fNodeCacheList: '; | |
res += toHtml(it.fNodeCacheList); | |
res += ' <br/>firstChild: '; | |
res += toHtml(it.firstChild); | |
if (it.firstChild != null) { | |
var child = it.firstChild; | |
while (child != null) { | |
res += descNode(child); | |
child = child.nextSibling; | |
} | |
} | |
return res + '</div><hr/>'; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment