This project is able to resurrect Java objects from a standard HPROF format dump. The heart of it is a Javascript REPL, which can find and inspect objects and their relations.
Additionally you can write handlers, which can remove semantically irrelevant or hard to traverse structures into standard types. Eg. AtomicLong is rewritten to a simple long or TreeMap into a Javascript map.
REPL is GNU Readline compatible with history.
Commands:
- load <dump>: Loads a dump. (This clears the javascript memory implicitly, therefore you need to load libraries again.)
- loadlibrary <javascript file>: Loads a library javascript file.
- grepobj [string]: Gives back the list of classes which has at least one living instance. The optional argument is a case insensitive string contains match
- grepclass [string]: Gives back the list of known classes. The list can be restricted optionally.
- . or source: Executes a REPL script. (Can load libraries and dump also)
- rebuildcache: Rebuilds the cache structures on disk. (in case it is corrupt)
- reset: Creates a new emply REPL.
- exit: Go figure
Anything else is evaulated as javascipt. eg. function invocation must be ended with (). The result of the functions will be printed.
You can access statics using the class of the object. The attributes are stored under the "statics" attribute of the class.
eg.
logger.println(var.type.statics.variable);
Staitics behaves like an object:
describeObject(var.type.statics.variable);
There are two methods to access the back-references:
- obj.getBackReferences() : Returns all objects referencing the given object.
- obj.getBackReferenceIds() : Returns all object ID to the given object.
- obj.findReferenceHolder(ObjectId) : Returns the name of the holder field
Default library contains some handy functions for interaction with the given dump:
The factory reference represents the loaded dump. You can use the following methods:
- factory.getSnapshotTime() : Date: Time when the dump was taken
- factory.getObject(long) : Object: Returns an object reference by objectid
- factory.getRawObject(long) : Object: Returns an object reference by objectid without post processing.
- factory.findAll(string) : List<Object>: Finds all instances of a class. List supports getRaw() to get the unprocessed variant.
Register handler can help resolving complex objects.
eg.
RegisterHandler("org.apache.activemq.command.BrokerId", function (obj) {
return obj.value;
});
Formats time as time difference from the snapshot time.
Prints all attributes of an object
Prints all attributes of an object by object id.
Prints all attributes of an object by object reference
Shows a swing dialog with a tree the incoming references.
Displays the relation between the holder and the referenced object.
When after loading the dump a cache will be created. This might take up to 2x the hprof size. The reason being is that all object fields are copied over to an own db. Hprof file is not used anymore during operation.