In sa.js dumpheap is implemented as:
registerCommand("dumpheap", "dumpheap [ file ]", "dumpHeap");
The 3rd argument is the implementation. In this case it is a java method in JSJavaScriptEngine.java, which does the following:
public Object dumpHeap(Object[] args) {
String fileName = "heap.bin";
if (args.length > 0) {
fileName = args[0].toString();
}
return new JMap().writeHeapHprofBin(fileName)? Boolean.TRUE: Boolean.FALSE;
}
So this java code is easily moved to CommandProcessor.java
registerCommand("dumpheap", "dumpheap [ file ]", "dumpHeap");
The 3rd argument is the implementation. In this case it is a java method in JSJavaScriptEngine.java, which does the following:
public Object dumpHeap(Object[] args) {
String fileName = "heap.bin";
if (args.length > 0) {
fileName = args[0].toString();
}
return new JMap().writeHeapHprofBin(fileName)? Boolean.TRUE: Boolean.FALSE;
}
So this java code is easily moved to CommandProcessor.java