I am willing to write the value of a large StringBuilder with index 827 to disk. I am trying to do that using the following OQL:
map(heap.objects('java.lang.StringBuilder'),
function(it, index) {
if (index == 827.0) {
var writer = new java.io.FileWriter("/Users/username/output/sb_0x" + it.id.toString(16) + ".txt");
var chars = it.value;
for (var i = 0; i < chars.length; i++) {
writer.write(chars[i]);
}
writer.close();
}
return index;
})
However, nothing gets written. I now that the builder exists, since I have inspected it:
All StringBuilder objects
It seems that the result gets truncated after the builder with index 99 (i.e. it works for 99, but doesn't work for 100):
Truncated after 100
Any suggestions how can I get the value of the StringBuilder with id 827?
You can use the following query:
filter(heap.objects('java.lang.StringBuilder'),
function(it, index) {
if (index == 827.0) {
var writer = new java.io.FileWriter("/Users/username/output/sb_0x" + it.id.toString(16) + ".txt");
var chars = it.value;
for (var i = 0; i < chars.length; i++) {
writer.write(chars[i]);
}
writer.close();
return true;
}
return false;
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With