Now if I want to dump a big string or char[] from heap dump.
I firstly get the address from heap analyzer
and then dump it to disk using
chars = heap.findObject("0x1111111")
var writer = new java.io.FileWriter("D:/temp/oql/chars.txt");
for (var i = 0; i < chars.length; i++) {
writer.write(chars[i]);
}
writer.close()
But it's annoying.
I need to use two tool to do one thing and waste both time and memory.
Instead of object address, What the visualVM provide is index:
So If I don't want to open Heap analyzer
I will use:
filter(heap.objects('char[]'),
function(it, index) {
if (index == 710394) {
var writer = new java.io.FileWriter("D:/temp/oql/chars.txt");
for (var i = 0; i < it.length; i++) {
writer.write(it[i]);
}
writer.close();
return true;
}
return false;
})
But it's slow when index is big.
I check the OQL to see if I can use index,but not found.
So Can I get the address directly by VisualVM(like index now),or any other way to simply dump to disk.