Skip to content

Instantly share code, notes, and snippets.

@pfn
Last active December 16, 2015 03:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfn/5373220 to your computer and use it in GitHub Desktop.
Save pfn/5373220 to your computer and use it in GitHub Desktop.
oql query
select { ary: s, sz: s.length, ref: forEachReferrer(
function refs(r) {
function cid(o) {
var cn = classof(o).name;
cn = cn.substring(cn.lastIndexOf(".") + 1);
return cn + "@" + objectid(o);
}
println(cid(s) + "=" + s.length + " <= " + cid(r) + " <= " +
toArray(map(sort(
referrers(r), "classof(rhs).name.length() - classof(lhs).name.length()"),
function(i) { return cid(i)}))
);
}, s) } from byte[] s where s.length >= 1000000;
select { data: map(
filter(heap.objects("byte[]", false), "it.length > 1000000"),
function(i) {
return toHtml({
b: i,
sz: i.length,
refs: referrers(i),
refrefs: sort(map(referrers(i), 'referrers(it)').nextElement(),
"lhs.toString().length() - rhs.toString().length()")
}) + "<br>";
}), sum: sum(filter(heap.objects("byte[]", false), "it.length > 1000000"),
"it.length")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment